Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用github中的另一个分支完全替换远程分支,不留下旧分支的痕迹_Git_Ssh_Push - Fatal编程技术网

用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

我将一个分支推送到一个空的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 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.
我不得不删除回购协议,重新推出我的新分行。这很管用,但让我想:

  • 我应该怎么做才能完全替换远程分支 另一个

  • 究竟为什么我要得到ssh:connecttohost端口 22:错误的文件号错误-当我的第一次推送成功时(注意我在http上)


  • 你的语法错了。正确的命令是:

    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