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.
过去多啦不再A梦2017-06-23 09:14:17
It has nothing to do with whether it is pushed to the remote. Even if push
is done, you can still push -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
. Where A
is the original starting point (master), B C D E F
is from uop-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'
欧阳克2017-06-23 09:14:17
Git has a cherry-pick command, I don’t know if it meets your needs. Please download the usage from Baidu
阿神2017-06-23 09:14:17
If you only performed the operation locally and have not pushed it to the upstream server, you can use git rebase
to rebase uop-151
to master
.
Official Git Rebase documentation (need to circumvent the wall)
https://git-scm.com/docs/git-...
Other reference documents
http://blog.csdn.net/hudashi/...
代言2017-06-23 09:14:17
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.