Git Pycharm仅将本地主分支更改为与原始主分支完全相同

时间:2019-11-28 10:14:20

标签: python git pycharm

我有2个本地分支:“ master”和“ fix”。 我也有一个源远程仓库,它的主分支与本地主分支不同。

“ fix”分支曾经是master分支的副本,但是后来我做了很多更改: 我更改了一些文件,重命名了其他文件,添加了新文件并删除了一些文件。

现在,我希望我的本地master分支与远程master分支相同-无需更改“ fix”分支!

当我使用git pull时,它不会从远程存储库中提取所有文件。我不知道为什么。 当我使用git reset --hard origin/master时,它确实使本地主机与远程主机相同(这正是我想要的),但是它也将文件添加到“修复”分支中!

  1. 这为什么会大幅度增加?
  2. 如何在不更改“修复”分支的情况下做到这一点?

1 个答案:

答案 0 :(得分:0)

您需要先对fix分支进行更改,然后再切换到master分支

#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

我希望它会有所帮助:)

相关问题