I created a new branch uop-151, which is based on uop-387, but I want to build it based on the main branch, but now it has been developed and submitted, but I only want to submit uop-151's stuff, not uop- 387, how to deal with it?
I only want to submit the top commit, and I don’t want to submit the following commits. The main thing is that I have pushed to the remote branch.
It has nothing to do with whether it is pushed to the remote. Even if
push
is done, you can stillpush -f
to modify it. .In this case, just use
git rebase --onto
. Documentation: https://git-scm.com/docs/git-...Your situation can be abstracted into:
A - B - C - D - E - F - G
. WhereA
is the original starting point (master),B C D E F
is fromuop-387
, and you don’t want it.G
is your own commit and should be kept.Execute
git checkout uop-151
first to make sure you are on the branch you want to operate.Then
git rebase --onto uop-151~6 uop-151~1 uop-151
Result:
A - G'
Git has a cherry-pick command, I don’t know if it meets your needs. Please download the usage from Baidu
If you only performed the operation locally and have not pushed it to the upstream server, you can use
git rebase
to rebaseuop-151
tomaster
.Official Git Rebase documentation (need to circumvent the wall)
https://git-scm.com/docs/git-...
Other reference documents
http://blog.csdn.net/hudashi/...
Cherry-pic the commit id of your development submission to master.
If you haven’t pushed yet, you can perform the
git reset xxxx
operation on the uop-387 branch. Where xxxx is the latest hash of the uop-151 branch.Then switch to the master branch and build a branch based on master again. Don’t forget to use the
--merge
parameter.If you are familiar with git, you can use the cherry-pic command.
After checking out the main branch, just create a new branch.