SourceTree’s equivalent git commands

Vyom Vajpai
Jul 10, 2017 · 2 min read

  1. Clone
git clone <url>

Cloning a remote repository into our local file system can be done this way.


2. Initialization

cd <dir_name>
git init

This will create a local git repository, which we can push later to remote server

You can also add template of a project, which will copy the folder structure into your newly created local repo

git init <directory> --template=<template_directory>

3. Fetch

git fetch

Fetches all the commits from remote to local working copy

git fetch <branch_name>

Fetches all the commits from just the specified branch


4. Pull

git pull <remote>

Fetches the commit from remote and merges them with local working copy

git fetch <remote>
git merge origin/<current_branch>

This does the same work as git pull <remote>


5. Push

git push <remote> <branch_name>

Push the local changes to remote repository


6. Branch

git branch
> lists out the branched in given repo
git branch <branch_name>
> create a branch with a given name

Although creating a branch doesn’t implicitly checks out that branch.

This can be done using

git checkout -b <new-branch>

7. Checkout

git checkout <branch_name>

checks out a remote branch and merges it with local copy


8. Merge

git merge <branch_name> <feature_branch_name>

Merges the feature branch into a branch

Suggested Reading : Difference between rebase and merge


9. Tag

git tag

Lists out all the tagged commits alphabetically.

git show <tag_name>

Shows the tagger information and other metadata associated

git tag -a vX.YY -m "your message here"

Creates tag on the head with specified tag and message

git tag -a vX.YY <commit_checksum>

This will add tag to a previous commit

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade