git重置本地存储库分支,就像远程存储库分支(Myremote分支)一样
我正在尝试使用git做一些事情。
我有以下命令来获取和“清洁”我当前的分支,并将其(我当前的分支)与远程分支原始/主人完全相同:
git fetch
git reset --hard origin/master
这在工作。
现在,我想让我的当前分支与名为Myremotebranch的远程分支完全相同。 这是,我不想使我的当前分支与Origin/Master相同,而是想做与Myremotebranch(远程分支)相同的当前分支。
通过:
git fetch
git reset --hard origin/myremotebranch
我可以做到吗? (使我当前的本地分支就像远程分支一样?
I am trying to do some stuff using git.
I had the following commands to fetch and to "clean" my current branch and to make it (my current branch) exactly the same as the remote branch origin/master :
git fetch
git reset --hard origin/master
This is working.
Now I'd like to make my current branch exactly the same as remote branch named myremotebranch.
This is, instead of making my current branch the same as origin/master, I'd like to do my current branch the same as myremotebranch (remote branch).
By doing:
git fetch
git reset --hard origin/myremotebranch
Can I accomplish this? (make my current local branch just like remote remotebranch?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您的重置命令将正如您描述的。但是,您无需拥有本地分支即可转移到另一个提交。您可以直接查看提交:
这将使您进入独立的头状态。无需始终重置分支。
Yes, your reset commands will work as you describe. But you don't need to have a local branch to move to a different commit. You can check out commits directly:
This will get you into detached HEAD state. No need to have a branch to be reset all the time.