Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Squashing commits: combining multiple existing commits

Example: I have three commits on my branch for a single Jira ticket. I would like to squash them into a single commit before pushing to my branch and creating a pull request.

While on my branch, type:

...

Code Block
languagebash
pick afb581 IGBF-3379: Fix DAS annotations
squash 643d0e IGBF-3379: Fix typo
squash 87871a IGBF-3379: Fix second typo

Save and then close the editor.

The editor will open again showing the commits and their messages. 

Code Block
languagebash
# This is a combination of 3 commits.
# This is the 1st commit message:

IGBF-3379: Fix DAS annotations

# This is the commit message #2:

IGBF-3379: Fix typo

# This is the commit message #3:

IGBF-3379: Fix second typo

My preference is to remove the commit messages for the two squashed commits. You can also update the initial commit message if needed.

Code Block
languagebash
# This is a combination of 3 commits.
# This is the 1st commit message:

IGBF-3379: Fix DAS annotations and typos

# This is the commit message #2:


# This is the commit message #3:

Save and then close the editor.

Fetch another developer's branch for testing

Example: I have been asked to test changes made to IGB on another developers branch as part of a 1st level review.

Find the developers IGB repository URL.

Type the following in a terminal or git bash:

Code Block
languagebash
git fetch https://bitbucket.org/nfreese/nowlanfork-igb.git IGBF-3379:IGBF-3379-myBranch
git checkout IGBF-3379-myBranch

This will fetch the branch IGBF-3379 from the developer's repository, and it will call that branch IGBF-3379-myBranch on your local machine. You can then checkout the branch and test it.

Note: This local branch will not track the developer's remote branch.