Sourcetree Cheat Sheet

This Git cheat sheet saves you time when you just can't remember what a command is or don't want to use git help in the command line. It is hard to memorize all the important Git commands by heart, so print this out or save it to your desktop to resort to when you get stuck. Git Cheat Sheet Day-To-Day Work $ git status Displays the status of your working directory. Options include new, staged, and modified files. It will retrieve branch name, current commit identifier, and changes pending commit. $ git add file Add a file to the staging area.

SourceTree General Setup¶

Prerequisites¶

Sourcetree Cheat Sheets

Command Cheat Sheet (Frequent Commands) git status git log git add git commit git checkout git reset These Comm ands are Local! (what's up on my drive) (what happened so far) (prepare these files for commit) (commit the added files) (return to a previous version) (reset the git index). Should I use GitKraken or SourceTree for Git? This handy flowchart asks the important, probing questions that get to the bottom of who you really are, and whether you should be using GitKraken, GitKraken Pro, or SourceTree for your Git workflow.

In order to use SourceTree in Windows PuTTY should be installed and your SSH key loaded into pageant(see Create SSH key on Microsoft Windows).

Installation¶

Sourcetree Cheat Sheet
  1. Download SourceTree at https://www.atlassian.com/software/sourcetree
  2. Execute the installer

Basic Settings¶

First of all set the basic settings for your Git configuration by clicking on the settings button in SourceTree andadd your name, email and SSH Key. Make sure the option “SSH Client” is set to PuTTY/Plink.

Clone¶

To clone a new repository click on “Clone/New”.

Enter the URL to your repository and the path to your local folder. For easier access to your repositoriesleave the bookmark check box checked.

Click on Clone. Checking out the full TYPO3 Core repository might take some time, please be patient.

Automatic links to Forge and Gerrit¶

The commit messages contain a reference to the corresponding Forge ticket and a Gerrit review link. To get directlinks from SourceTree choose the Core repository bookmark on the left and then click on the Settings button in thetop bar. Choose tab “Advanced” and click “Add” at the section for “Commit text links”:

Cheat

Choose “Replacement type:” “Other” and add

  • Regex pattern: (#)+((?:[0-9]*)?)
  • Link to URL: https://forge.typo3.org/issues/$2

Sourcetree Cheat Sheet Pdf

Repeat the steps for the Gerrit links and add

  • Regex pattern: (https://review.typo3.org/.*)
  • Link to URL: $1

After adding these two settings your commit history now shows links:

Reviewing and testing patches¶

Update the repository¶

Before applying a patch you should update the repository to its latest state. Press the pull button from the main buttonbar:

Then click OK:

Cherry-picking¶

First visit the page of the patch in Gerrit. From the Download menu, choose the copy button after the ‘Cherry Pick’ line.

The next step has to be done via the command line. Open git bash by pressing “Terminal” and paste the copied line withthe ‘Ins’ button:

The patch is now applied and you can start testing.

Creating patches¶

Commit hook¶

In each folder that contains a repository you need to execute the following command to install a Git hook which adds a uniqueChange-Id to the commit message (and performs a few checks). Choose the repository from your bookmarks and click “Terminal”to open a git bash for that repository. Copy the following command to the bash and execute it:

Note

You can read about the why and where of the pre-commit hook here.

Setup for pushing to Gerrit¶

In the Git Bash window (click Terminal), enter the following commands to set that you push to Gerrit instead of the TYPO3 repository directly.

Create a branch¶

It’s easier to undo all the changes in a patch if you create a branch for it. Click on the branch button and entera name for your new branch, then click “Create Branch”.

Now start coding and commit your changes (By pressing the “Commit” button). Make sure your commit message is writtenaccording to the >>>rules for the commit message<<< and click OK.

Your changes are now stored locally in a separate branch.

Send the patch to Gerrit¶

Click the “Push” button to open the push dialog.

Check the checkbox in front of your feature branch. As remote branch add “refs/for/master” - which will create a new patchsetfor master. If you want to create patches for older branches use ‘refs/for/<branchName>’, for example ‘refs/for/TYPO3_6-2’.Be aware that you have to fix a bug in master first before it can go to older branches.

Now click ok. You should get a Gerrit link to your new change in the resulting output.

Cleaning up¶

Sourcetree cheat sheets

To get back to master just click on it at the “Branches” section. If you want to delete your feature branch,right click on it and choose “Delete”.

To add your supply request file, do the following:

  1. From your BitbucketStationSupplies in Bitbucket, click Source to open the source directory. Notice you only have one file, supplies.txt, in your directory.

    • A. Source page: Click the link to open this page.

    • B. Branch selection: Pick the branch you want to view.

    • C. More options button: Click to open a menu with more options, such as 'Add file'.

    • D. Source file area: View the directory of files in Bitbucket.

  2. From the Source page, click the More options button in the top right corner and select Add file from the menu. The More options button only appears after you have added at least one file to the repository. A page for creating the new file opens, as shown in the following image.

    • A. Branch with new file: Change if you want to add file to a different branch.

    • B. New file area: Add content for your new file here.

  3. Enter supplyrequest in the filename field.

  4. Select HTML from the Syntax mode list.

  5. Add the following HTML code to the text area:

    We are requesting additional supplies. Please send us the following:



    • space ice cream

    • nerf darts

    • telescope light shield

  6. Click Commit. The Commit message field appears with the message: supplyrequest created online with Bitbucket.

  7. Click Commit under the message field.