Sitemap
Imal Kumarage

Imal Kumarage

Git Cheat Sheet

1 min readJul 13, 2021
Press enter or click to view image in full size
  • Initialize a git repository locally
git init
  • Clone a remote repository
git clone <url>
  • Clone a specific branch. In this case the branch ‘develop’
git clone -branch develop <url>
  • Staging/Adding files and directories
git add .  ---> Add all files in current directory
git add ./path/to/folder ---> Add all files in specific directory
git add test.txt ---> Add single file
  • Commit all added/staged files
git commit -m "Commit message"

    Get Imal Kumarage’s stories in your inbox

    Join Medium for free to get updates from this writer.

  • Create a new branch in local repository
git checkout -b branch_name
  • Pull master branch and merge with current local branch
git pull origin master
  • Push changes to branch in remote repository. (If no branch exists branch is created in remote)
git push origin branch_name
  • Fetches all remote refs (reference to remote branches)
git fetch
  • Checkout remote branch (As long as you have only one remote)
git checkout remote_branch_name
  • Untrack file/folder and remove from repository without deleting actual physical file
git rm --cached file_name

--

--