我有2个本地分支:“ master”和“ fix”。 我也有一个源远程仓库,它的主分支与本地主分支不同。
“ fix”分支曾经是master分支的副本,但是后来我做了很多更改: 我更改了一些文件,重命名了其他文件,添加了新文件并删除了一些文件。
现在,我希望我的本地master分支与远程master分支相同-无需更改“ fix”分支!
当我使用git pull
时,它不会从远程存储库中提取所有文件。我不知道为什么。
当我使用git reset --hard origin/master
时,它确实使本地主机与远程主机相同(这正是我想要的),但是它也将文件添加到“修复”分支中!
答案 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
我希望它会有所帮助:)