Skip to content

Git tips

Richard Domander edited this page Sep 12, 2018 · 6 revisions

Here are some quick tips for working with Git on BoneJ.

For bug fixes and new features it's recommended to create a new topic branch. When you've added all the necessary commits create a pull request (PR), and have it reviewed if possible. If the PR has merge conflicts, merge master to the topic branch with:

// Let's synchronize local master branch first
git checkout master     
git fetch origin
git pull
// Merge topic-branch with master
git checkout topic-branch
git merge master

after the conflicts have been solved, and the review completed, you can merge the PR with master.

When adding a larger feature like whole new wrapper plug-in with ops, it's better to divide it into several PRs, which add the functionality piece by piece. This way reviewing, merge conflicts and commit cleaning stay manageable. If the pieces cannot be added independent of each other, you can always branch the next piece from the last commit of the previous. For example, let's say you've completed the topic branch cool-op1 and created a PR. The reviewer's gone to make coffee, but you want to start working on cool-op2 now. Now you just type git checkout -b cool-op2 while you're on the cool-op1 branch instead of master. If the cool-op1 PR has been merged to master before cool-op2 is ready, then eventually you create a PR from it like always. If not, then you create PR, that uses cool-op1 as its base, i.e. you merge the two topic branches.

The most important thing to realize about working with Git is that nothing you do is irreversible. So be brave and commit early and commit often, but learn how to fix things.

  • Calling git commit -a starts a new commit that includes all changed files.

  • When adding files to a commit, you can use tab-completion, directories and wild-cards. For example, running git add src/test/ adds all changed files in path src/test/ to the commit.

  • If, for example, you notice you've been working on the wrong branch

Clone this wiki locally