我正在使用Git 2.27.0版本。
我犯了一个错误。
我应该运行此命令来切换到另一个分支:
git checkout CTNG-52-flight-result-form-changes
但是我改为运行此命令:
git branch CTNG-52-flight-result-form-changes
问题
现在,这已CTNG-52-flight-result-form-changes
在我的本地仓库中创建。CTNG-52-flight-result-form-changes
已经存在于远程仓库中,现在我不想对远程仓库进行任何更改,但是我只想签出远程仓库分支(CTNG-52-flight-result-form-changes
)。
题
如何还原git branch CTNG-52-flight-result-form-changes
命令而不影响远程仓库上的任何内容?
更多信息
这是我运行的命令的日志:
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git branch
* develop
login-changes
master
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git fetch
remote: Counting objects: 1598, done.
remote: Compressing objects: 100% (831/831), done.
remote: Total 1598 (delta 1159), reused 1075 (delta 752)
Receiving objects: 100% (1598/1598), 425.01 KiB | 773.00 KiB/s, done.
Resolving deltas: 100% (1159/1159), completed with 39 local objects.
From https://bitbucket.org/travellinckcorpdevelopers/nexct-ng-ui
* [new branch] 53-flight-results -> origin/53-flight-results
* [new branch] CS-BookANewTrip -> origin/CS-BookANewTrip
* [new branch] CS-Dashboard-Develop -> origin/CS-Dashboard-Develop
* [new branch] CS-request-newdashtrip -> origin/CS-request-newdashtrip
* [new branch] CS-update-my-trips -> origin/CS-update-my-trips
* [new branch] CTNG-24-my-trips-page -> origin/CTNG-24-my-trips-page
* [new branch] CTNG-25-book-new-trip -> origin/CTNG-25-book-new-trip
* [new branch] CTNG-25-request-a-trip -> origin/CTNG-25-request-a-trip
* [new branch] CTNG-52-flight-result-form-changes -> origin/CTNG-52-flight-result-form-changes
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git branch
* develop
login-changes
master
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git branch CTNG-52-flight-result-form-changes
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git branch
CTNG-52-flight-result-form-changes
* develop
login-changes
master
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git checkout CTNG-52-flight-result-form-changes
M nexct-ng-ui/package-lock.json
Switched to branch 'CTNG-52-flight-result-form-changes'
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git pull
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:
git config pull.rebase false # merge (the default strategy)
git config pull.rebase true # rebase
git config pull.ff only # fast-forward only
You can replace "git config" with "git config --global" to set a default
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git branch
* CTNG-52-flight-result-form-changes
develop
login-changes
master
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git checkout develop
M nexct-ng-ui/package-lock.json
Switched to branch 'develop'
Your branch is up to date with 'origin/develop'.
Richards-MacBook-Pro:nexct-ng-ui richardmarais$ git branch
CTNG-52-flight-result-form-changes
* develop
login-changes
master
有了您,git branch CTNG-52-flight-result-form-changes
您就创建了一个名称为CTNG-52-flight-result-form-changes的分支,该分支不会跟踪任何远程分支,因此可以使用以下命令自由删除它:
git branch -d CTNG-52-flight-result-form-changes
为了从遥控器签出CTNG-52-flight-result-form-changes并将您的本地副本设置为跟踪遥控器,请使用以下命令:
git checkout -b CTNG-52-flight-result-form-changes origin/CTNG-52-flight-result-form-changes
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句