Completely replace remote branch with another in github leaving no traces of the old one
Your syntax is wrong. The correct command is:
git push -f github GitHubSquash
This will replace the remote GitHubSquash branch with your local version. If you just want to delete the remote branch:
git push -f github :GitHubSquash
I guess you got your error, because git is trying to interpret :github
as an url and weird stuff happens :).
Mr_and_Mrs_D
Be warned - the Monster isAlife Git, Java, Android and finally Python I was flirting with JEE since a couple years but since 1/2014 we are having an affair I spent the best part of the last year refactoring a widely used mod manager application. Here is the commit message of the release I have been working on, where I detail what I have been doing: https://github.com/wrye-bash/wrye-bash/commit/1cd839fadbf4b7338b1c12457f601066b39d1929 I am interested in code quality and performance (aka in the code as opposed to what the code does) If you find my posts useful you can buy me a coffee TCP walks into a bar & says: “I’d like a beer.” “You’d like a beer?” “Yes, a beer.”
Updated on June 12, 2022Comments
-
Mr_and_Mrs_D almost 2 years
I pushed a branch to an empty github repo :
MrD@MRSD /c/Dropbox/eclipse_workspaces/javaEE/ted2012 (GitHubSquash) $ git remote add github https://github.com/Utumno/ted2012.git MrD@MRSD /c/Dropbox/eclipse_workspaces/javaEE/ted2012 (GitHubSquash) $ git push -u github GitHubSquash Username for 'https://github.com': Utumno Password for 'https://[email protected]': //... To https://github.com/Utumno/ted2012.git * [new branch] GitHubSquash -> GitHubSquash Branch GitHubSquash set up to track remote branch GitHubSquash from github.
Then I noticed I had pushed some fluff along and tried to delete the branch/replace it with another etc. I failed :
MrD@MRSD /c/Dropbox/eclipse_workspaces/javaEE/ted2012 (GitHub2) $ git push :github && git push github GitHub2 ssh: connect to host port 22: Bad file number fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. MrD@MRSD /c/Dropbox/eclipse_workspaces/javaEE/ted2012 (GitHub2) $ git checkout GitHubSquash Switched to branch 'GitHubSquash' Your branch is ahead of 'github/GitHubSquash' by 1 commit. (use "git push" to publish your local commits) MrD@MRSD /c/Dropbox/eclipse_workspaces/javaEE/ted2012 (GitHubSquash) $ git push :github ssh: connect to host port 22: Bad file number fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. MrD@MRSD /c/Dropbox/eclipse_workspaces/javaEE/ted2012 (GitHubSquash) $ git push -u :github ssh: connect to host port 22: Bad file number fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
I had to delete the repo and push my new branch anew. That worked but left me wondering :
What should I have done to completely replace the remote branch with another ?
Why on earth I was getting the ssh: connect to host port 22: Bad file number errors - while my first push succeeded (and notice I am on http) ?
$ git --version git version 1.8.1.msysgit.1