In local repo:
git checkout -b feature/db/projectImport dev
git add.
and git commit
git push origin feature/db/projectImport
(staying in that branch) Now in GitHub:
5. Click the Compare & pull request button and finally merge with the default merge button, which claim to use --no-ff
feature
branch into dev
, the feature branch will retain all its commits but the dev
branch will only have the merge commit. Is this possible???Feature branch commits:
Dev branch commits:
Note:
git
. So, my thinking can be wrong. If this is the case, please point out my mistake and tell what is correct.As others have pointed out in the comments, what you are looking for is the squash option when you merge the PR in.
When you squash-merge, that changes what appears on the destination branch, but it does not change what is on the source branch. So on dev, you'll see one commit. But on the feature branch, as long as you don't delete it, you'll continue to see all your original feature commits. And the PR will continue to hold a pointer to that branch.
Now, that's a bit of a funny workflow to me: when I merge a PR in, I systematically delete the feature branch. But your workflow should work fine too.
Once you have your PR ready to merge, make sure you merge it in using GitHub's "squash and merge" method:
If you're doing the merge on your own computer, the same operation can be accomplished like this:
git checkout dev
git merge --squash feature/feature-name
git push origin dev
With either method, you will get to write a new message for the squashed commit that will get added to dev
.
Once you've completed the merge, dev
will have one new commit, and branch feature/feature-name
will remain unmodified.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.