Git Cheat Sheet

You can translate the content of this page by selecting a language in the select box.

Find Useful Git commands in this Git Cheat Sheet.

Here is a basic Git cheat sheet:

Achieve AWS Solutions Architect Associate Certification with Confidence: Master SAA Exam with the Latest Practice Tests and Quizzes illustrated

git init – Initialize a new git repository

git clone [repository] – Clone an existing repository

git status – Check the status of your repository

git add [file] – Add a file to the repository

Ace the AWS Certified Machine Learning Specialty Exam with Confidence: Get Your Hands on the Ultimate MLS-C01 Practice Exams!

git commit -m "[message]" – Commit changes with a message

git push – Push changes to a remote repository

git pull – Pull changes from a remote repository

git branch – Show the current branch

git branch [branch-name] – Create a new branch

git checkout [branch-name] – Switch to a different branch

If you are looking for an all-in-one solution to help you prepare for the AWS Cloud Practitioner Certification Exam, look no further than this AWS Cloud Practitioner CCP CLFC01 book below.

git merge [branch-name] – Merge a branch into the current branch

git log – Show the commit history

"Become a Canada Expert: Ace the Citizenship Test and Impress Everyone with Your Knowledge of Canadian History, Geography, Government, Culture, People, Languages, Travel, Wildlife, Hockey, Tourism, Sceneries, Arts, and Data Visualization. Get the Top 1000 Canada Quiz Now!"

git diff – Show changes between commits

git reset --hard [commit] – Reset repository to a specific commit

git stash – Stash changes

git stash apply – Apply stashed changes

Please note that this is a basic cheat sheet and git has many more functionalities and options, it is worth reading the git documentation to learn more.

Invest in your future today by enrolling in this Azure Fundamentals - Pass the Azure Fundamentals Exam with Ease: Master the AZ-900 Certification with the Comprehensive Exam Preparation Guide!

Microsoft Azure AZ900 Certification and Training

  • Clone a project:
    git clone git_repo_url project_name
  • Switch to a branch locally:
    git checkout branch_name
  • Modify a file, then save and push it to remote repo in current branch
    git add path_to_file_modifeid/file_name
    git commit -m “Description of modification”
    git push
  • Get a new version of a file after modifying local version
    git checkout path_to_file_modified/file_modified
  • Get latest version of current branch
    git fetch
    git pull
    if you have local changes, you will be prompted to commit or stash them before pulling.
  • Create a new branch based on current branch and switch to it
    git checkout –b branch_name
  • Switch to master branch
    git checkout master
  • Merge branch_name to master
    git merge branch_name
  • Delete local branch
    git branch -d branch_name
  • Undo a merge or pull
    git reset –hard
  • Undo a commit locally and on the remote branch
    git reset –hard commit_id
    git push –force
  • Get remote url of a local branch
    git remote show origin


error: Content is protected !!