I forked repo vanilla
via github
interface to vanilla_copy
, after that I do: git clone vanilla_copy
, after some time I do git pull
and get one new commit feature A
, and my history now looks like
Merge remote-tracking branch 'upstream/master'
feature A
after I commit something my self it become:
feature created by me
Merge remote-tracking branch 'upstream/master'
feature A
At now I want to create pull request
to vanilla
,
is it normal that my commit feature created by me
have parrent that not exists in vanilla
repo?
How I should use git
to not create this auto merge commit
, use git pull --rebase
or track vanilla/master
via vanilla_copy/upstream
and use git rebase branch
or some other mechanizm?
How should I remove this existing merge commit? Should I remove commit via git rebase -i
and then git push -f
as described here: Delete Github commit history ?
In order to keep git repos easy to navigate, i squash my commits down to a few, or one, discreet changesets before submitting a pull request. Fixing a bug will usually only need one commit, while a larger feature might contain a couple of separate improvements that is easier to track through different commits.
Once you have rebased your work on top of the latest state of the upstream master, you may have several commits related to the issue you were working on. Once everything is done, squash them into a single commit with a descriptive message, like "Issue #100: some bugfix."
To squash four commits into one, do the following:
$ git rebase -i HEAD~4
In the text editor that comes up, replace the words "pick" with "squash" next to the commits you want to squash into the commit before it. Save and close the editor, and git will combine the "squash"'ed commits with the one before it. Git will then give you the opportunity to change your commit message to something like, "Issue #100: Fixed some bug."
Important : If you've already pushed commits to GitHub, and then squash them locally, you will have to force the push to your branch.
$ git push origin branch-name --force
Helpful hint: You can always edit your last commit message, before pushing, by using:
$ git commit --amend
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.