用github中的另一个分支完全替换远程分支,不留下旧分支的痕迹
我将一个分支推送到一个空的github回购:用github中的另一个分支完全替换远程分支,不留下旧分支的痕迹,git,ssh,push,Git,Ssh,Push,我将一个分支推送到一个空的github回购: 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 GitHu
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://Utumno@github.com':
//...
To https://github.com/Utumno/ted2012.git
* [new branch] GitHubSquash -> GitHubSquash
Branch GitHubSquash set up to track remote branch GitHubSquash from github.
然后我注意到我推了一些绒毛,并试图删除分支/用另一个分支替换它。我失败了:
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.
我不得不删除回购协议,重新推出我的新分行。这很管用,但让我想:
你的语法错了。正确的命令是:
git push -f github GitHubSquash
这将用本地版本替换远程GitubSquash分支。如果您只想删除远程分支:
git push -f github :GitHubSquash
我猜你是有错误的,因为git试图将:github
解释为url,奇怪的事情发生了:)
删除远程分支的步骤
git push --set-upstream origin GitHubSquash
推动地方分行
git push origin :GitHubSquash
git push --set-upstream origin GitHubSquash