Stage everything in the directory for an initial commit: git add. Stage changes for the next commit: git add Merge the specified branch with the current branch: git merge Making Changes Rename a branch you are currently working in: git branch -m
#Mac terminal commands cheat sheet how to
Note: For a more detailed tutorial on working with Git branches, you can refer to our article on How to Create a New Branch or How to Switch Branches in Git.ĭelete a local branch: git branch -d Switch to a branch under a specified name (if it doesn’t exist, a new one will be created): git checkout List all branches in the repository: git branchĬreate a new branch under a specified name: git branch See the difference between the last commit and the working directory: get diff HEADĭisplay the content and metadata of an object (blob, tree, tag or commit): git show Git Branches Įxamine the difference between the working directory and the index: git diffĮxplore the difference between the last commit and the index: get diff -cached List all commits from all branches: git log -allĬompare two branches by showing which commits from the first branch are missing from the second branch: git log. List the commit history of the current branch: git log Show the state of the current directory (list staged, unstaged, and untracked files): git status Open Git’s global configuration file: git config -global -edit Managing Files Set a default text editor: git config -system core.editor For example, you can use the alias st for the status command by typing the command: git config -global alias.st status You can check that by using the type command. Some commands are builtin and some commands are external programs. That program is called shell, which runs inside the Terminal. In order to use commands youll need a program that reads and executes them. Setting shortcuts for commonly used commands can speed up and simplify development. My personal cheatsheet for the Mac OS Terminal. Note: Git requires you to type out the entire command to perform actions.