![](/img/trans.png)
[英]How do I change a feature branch of a local git repo without changing the master branch?
[英]Git Pycharm change only the local master branch to be exactly like origin master branch
我有 2 个本地分支:“master”和“fix”。 我还有一个 origin 远程仓库,其 master 分支与我的本地 master 分支不同。
“修复”分支曾经是主分支的副本,但后来我做了很多更改:我更改了一些文件,重命名了其他文件,添加了新文件并删除了一些文件。
现在,我希望我的本地 master 分支与远程 master 分支相同 - 不更改“修复”分支!
当我使用git pull
它不会从远程存储库中提取所有文件。 我不知道为什么。 当我使用git reset --hard origin/master
,它确实使本地 master 与远程 master 相同 - 这就是我想要的 - 但它也会将文件添加到“修复”分支!
在切换到master
分支之前,您需要将更改提交到fix
分支
#current branch: fix
git add .
git status # to verify that every thing is ready to be committed
git commit -m "your commit message"
git checkout master
# current branch: master
git status # to verify if you have commits that weren't yet pushed
git pull # add --rebase option if you have some commits not yet pushed to avoid adding merge commit
我希望它有帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.