当运行git状态时,我得到以下信息
Your branch is ahead of 'origin/master' by 3 commits.
我在其他一些帖子上读过,解决这个问题的方法是运行git拉—rebase,但rebase到底是什么,我会丢失数据吗,还是这是与主同步的简单方法?
当运行git状态时,我得到以下信息
Your branch is ahead of 'origin/master' by 3 commits.
我在其他一些帖子上读过,解决这个问题的方法是运行git拉—rebase,但rebase到底是什么,我会丢失数据吗,还是这是与主同步的简单方法?
当前回答
使用这4个简单的命令
步骤1:git checkout <branch_name>
这是很明显的分支。
步骤2:git拉-s递归-X their
获取远程分支变更,并在发生冲突时替换它们的变更。 在这里,如果你使用git状态,你会得到这样的东西,你的分支领先'origin/master' 3次提交。
步骤3:git reset——hard origin/<branch_name> . zip
步骤4:git取回
硬重置你的分支。
享受。
其他回答
使用这4个简单的命令
步骤1:git checkout <branch_name>
这是很明显的分支。
步骤2:git拉-s递归-X their
获取远程分支变更,并在发生冲突时替换它们的变更。 在这里,如果你使用git状态,你会得到这样的东西,你的分支领先'origin/master' 3次提交。
步骤3:git reset——hard origin/<branch_name> . zip
步骤4:git取回
硬重置你的分支。
享受。
没有什么可以解决的。您只是进行了3次提交,还没有将它们移动到远程分支。有几个选项,取决于你想做什么:
Git push:将更改移动到远程(如果远程上已经有其他更改,这可能会被拒绝) 什么都不做,继续编码,改天再同步 Git pull:从远程获取更改(如果有的话),并将它们合并到您的更改中 Git pull——rebase:如上所述,但尝试在远程更改之上重做你的提交
您处于典型的情况(尽管通常在大多数工作流中您不会在master上投入很多)。下面是我通常会做的事情:检查我的更改。也许可以做一个git rebase -interactive在它们上做一些修饰,删除那些糟糕的,重新排序使它们更有逻辑。现在用git push将它们移动到远程。如果这被拒绝,因为我的本地分支不是最新的:git拉-rebase重做我的工作在最近的变化和git推再次。
有一次我在Bitbucket上合并了一个pull请求,我就遇到了这种情况。
我只需要做:
git fetch
我的问题解决了。我希望这对你有帮助!!
Git重置-硬源/主
使用这个命令
这条来自git的消息意味着您已经在本地repo中进行了三次提交,并且还没有将它们发布到主存储库。要运行的命令是git push{本地分支名称}{远程分支名称}。
The command git pull (and git pull --rebase) are for the other situation when there are commit on the remote repo that you don't have in your local repo. The --rebase option means that git will move your local commit aside, synchronise with the remote repo, and then try to apply your three commit from the new state. It may fail if there is conflict, but then you'll be prompted to resolve them. You can also abort the rebase if you don't know how to resolve the conflicts by using git rebase --abort and you'll get back to the state before running git pull --rebase.