Quantcast
Channel: adamprescott.net » git
Viewing all articles
Browse latest Browse all 6

Tracking Commits Across Branches with Git and SourceTree

$
0
0

When it comes to Git, SourceTree is definitely my tool of choice. However, I was surprised to find that there doesn’t appear to be any sort of built-in commit tracking to see which branches do and don’t contain a commit, similar to changeset tracking in Visual Studio. Now, that said, it’s pretty easy to do with Git, there’s just nothing that I could find baked into the SourceTree UI (Am I wrong? Let me know!).

So, if I need to do this, I click the Terminal button in SourceTree and run one of the following commands:

git branch --contains 
git branch -r --contains 
git branch -a --contains 

The -r and -a parameters can be used to check just Remote or All (local+remote) branches.

Now, SourceTree may not have this functionality built-in, but it can be added easily with a Custom Action. Here’s how you can create a custom action to track a commit across branches.

  1. In SourceTree (Windows, 1.6.21.0), go to Tools > Options and select the Custom Actions tab
  2. Click the Add button to create a new custom action
  3. Enter a caption, and select the option to Show Full Output; for Script to run, enter the path to git.exe; and enter the parameters (note the use of $SHA)
    create-custom-action
  4. Click OK to save that bad boy

With the custom action created, you can run it by right-clicking a commit and choosing Custom Actions > Track in Remote Branches.
context-menu

If you selected the option to show full output, the branches containing the commit will be listed in SourceTree.
output



Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images