Git 如何在正确的分支中转移提交?我将它推入到主功能中,而不是正确的功能分支中
我不太喜欢GIT,我有以下问题 我在BitBucket上创建了一个新的存储库,并创建了一个名为feature/skeleton的新功能分支 然后我犯了以下错误:我推错了分支(我将代码推到主分支中),如您所见:Git 如何在正确的分支中转移提交?我将它推入到主功能中,而不是正确的功能分支中,git,version-control,bitbucket,Git,Version Control,Bitbucket,我不太喜欢GIT,我有以下问题 我在BitBucket上创建了一个新的存储库,并创建了一个名为feature/skeleton的新功能分支 然后我犯了以下错误:我推错了分支(我将代码推到主分支中),如您所见: 我该怎么做才能将这个提交(ID=b3542a8)转移到正确的特征/骨架分支中呢?当您创建特征/骨架分支时,您可能遗漏了--无轨迹标志,因此您的分支指向原点/主节点。从概念上讲,您可以这样做: 将您的本地分支指向正确的上游分支(可能是origin/feature/skeleton),然后
我该怎么做才能将这个提交(ID=b3542a8)转移到正确的特征/骨架分支中呢?当您创建
特征/骨架分支时,您可能遗漏了--无轨迹标志,因此您的分支指向原点/主节点。从概念上讲,您可以这样做:
将您的本地分支指向正确的上游分支(可能是origin/feature/skeleton
),然后重新推送它
更改原点/主控形状以恢复到以前的状态
实现这一点的命令有(假设您的遥控器为原点):
就这样
# Get your local repo copy up to date
git fetch
# checkout your feature branch
git checkout feature/skeleton
# set the proper upstream
git branch --set-upstream-to=origin/feature/skeleton
# push out your branch to the proper remote branch
git push
# now we'll fix master by checking it out
git checkout master
# set master to the commit ID you want it to be on (maybe it's c6afa8f), if needed
git reset --hard c6afa8f
# replace the remote master
git push --force-with-lease