-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Git commands (to be added to CONTRIBUTING.md)
Having a pull request accepted can be a long journey. You may have added fix commits or the master branch may have been updated. So it’s recommended to cleanup your pull request to sanitize the commits (and commit messages) as well as rebasing on top of the latest master branch.
First, be sure that the EDITOR environment variable point to your favorite editor (vi, emac…). If you are not fluent with these, you can use nano or pico proposing a more user-friendly editing experience. Then, just issue
git rebase -i origin/main
It will launch the editor with the list of commits. For example:
pick 7a375c6 Replace the @BeforeAll with a Quarkus Test Resource
pick 4f56c8d Update quarkus version to 1.3.0.CR2
pick 73fdfb1 enable native build on java 11
To change the commit, or merge them, edit the first word of each line:
-
pick
orp
means that the commit it kept -
reword
orr
indicates you want to update the commit message -
squash
ors
merges the commit with the previous line. It will invite you to update the commit message as the 2 messages are merged. -
fixup
orf
is like squash but the commit message of the squashed commit is erased
For example:
pick 7a375c6 Replace the @BeforeAll with a Quarkus Test Resource
squash 4f56c8d Update quarkus version to 1.3.0.CR2
reword 73fdfb1 enable native build on java 11
Once you have indicated the actions you want to achieve, just save and exit the editor.
If you selected squash
or reword
, you will be invited to update the commit message.
If there is a conflict, you would need to fix the conflict and then git add
the conflicting files. Be sure that the code build before adding. Once you are happy, continue the rebase with git rebase —continue
.
Once the rebase is done, push your branch using the -f
flag (force push):
git push -f your_fork your_branch
Done!