Git,你的分支领先于原创/大师'由3个提交。该怎么办?

时间:2016-01-07 10:29:40

标签: git github version-control branch

Your branch is ahead of 'origin/master' by 3 commits.

嗨,正如您所看到的那样,消息很明显。

我不想通过做一些奇怪的事情搞砸这个。

不幸的是,我做了一些更改,然后从我的主分支提交而没有签出新的分支。

现在,每次我需要提取新代码时,git会尝试将我的分支与原点(项目源)合并。
因此,每当我尝试拉出当前的分支时,最终都要领先于原始/主要的'由N + 1提交。

真让我烦恼。任何的想法 ?提前致谢。

1 个答案:

答案 0 :(得分:0)

您现在可以打开一个新分支:

# create new branch based upon current state   
git checkout -b <new branch>

# delete the master with the "extra" commits
git branch -D master

# update your local repo
git fetch --all --prune

# checkout the master tot get the latest code 
# while your changes are left in your new branch
git checkout master