Git Workflow for Craties
1. Naming on branches
To prevent collisions of branch names, branches that are pushed to
remote should be prefixed with your preferred initials, e.g.
h/my-branch (for Haudi) or
s/other-branch (for Spanky)
2. Create branch
Make sure you branch from the latest commit on
git pull git checkout -b h/my-branch
3. Commit and push to remote
After you made your changes, commit your files locally:
git add index.html path/to/main.css git commit -a
You can amend a commit to the previous commit:
git commit -a --amend
This will create a new commit containing changes of both commits.
Then push to remote:
git push -u origin h/mybranch
4. Rebase with master
Note: This step is only necessary, if
master changed while you were working on your branch!
If there have been changes to
master in the meantime, the branch needs to be rebased with
git fetch git rebase origin/master git push -f origin h/mybrach
5. Pull request
Open pull request on Github and ask a person for code review. If there are no complaints/suggestions to the pull request, the reviewer comments with
ack and you can proceed with 7, otherwise 6.
If there are changes to the pull request necessary, do them locally and commit them as fixups:
git commit --fixup $(git rev-parse HEAD)
This will create a new commit and mark it as fixup, so it can be squashed automatically later on.
Then, again, push to master:
git push origin h/mybranch
Proceed with 5.
7. Squash commits
If your pull request is only a single commit, you can skip this step, otherwise you will need to 'clean up' your commits by squashing them. You can use the procedure also to rename commit messages.
git rebase -i origin/master
This will launches an interactive guide. Commits that have been committed with the
--fixup option are automatically marked as fixup, meaning that they are merged with the previous commit into a single commit. You can do that also manually.
When done, push your changes to remote:
git push -f origin h/my-branch
The outcome should be that you have a single commit (except you have multiple features that are clearly separate) for your pull request.
8. Merge into master
You can merge your pull request on Github.
If you prefer the command line:
git checkout master git pull git merge origin h/my-branch git push origin master