 Git Operations Reference
Git Operations ReferenceOne of the issues with the number of different GUIs and interfaces for git is that it can be difficult to communicate particular functions. Git is, at its core, a commandline program. Most everywhere online, you will see solutions and instructions for git in commandline form, because that is the one standardized interface across all platforms.
As such, it is important to know what all of the commands do, even if you do not plan on using the commandline interface extensively.
This is not a definitive list of git commands, and neither does it explain all of the functions of every command.
			If you have questions about a command or some of its functions, use the man command with the name of the command you want to look up as an argument
			(for example, man git-commit).
			If it's a git command, prefix git- to the command name.
			Or, if you don't want to use the commandline, you can just Google with the man command as your search query instead.
When you're using bash (Note: this is NOT cmd.exe!), there are a couple of things you need to keep in mind.
File paths in bash separate directories with forward slashes (/). Appending a slash to an argument will tell bash that you're referring specifically for a directory.
Referring to files and folders in the present working directory is done just by typing the filename (no prefixes).
					If you want to use an absolute path (from the root of the system), lead with a slash /. On Windows, the first folder under / is the drive letter, e.g. /c/ for C:.
You can move through multiple directories at once by separating each folder with a slash, for example:
/home/pt/Documents
There are a number of characters that the shell uses to denote various functions that take precedence over literals such as filenames. For the most part, filenames don't include these characters, but there is one that you will encounter often: the space.
Spaces are used in bash to delimit arguments. So, if you enter a filename that has a space in it the way you normally would, bash will separate everything before the space and everything after the space into two different arguments — preventing your command from functioning properly. So, if you want to pass a filename that has a space or other reserved character, you need to escape it with a backslash:
My\ File.txt
There are a number of other characters that are also reserved, such as parentheses, or even the backslash itself (if you have a backslash in a filename, you double it up: \\).
					All of these need to be escaped with a backslash. See here for a more complete list.
Optionally, if it's just spaces you're worried about, you can enclose the filename or literal in double quotes. Then you don't have to escape the spaces.
"My File.txt"
If you're typing something like a long filename (or some git references like branches), you can actually have the shell complete the text for you, provided that you've given the shell enough information to do autocompletion.
Start typing the first few characters of the file/folder/branch name, and then hit Tab. If you've given it enough information, it will complete the rest. However, if there are multiple references that have a similar name, bash will only autocomplete as much that is similar between the files. You will have to type the characters to differentiate it from the rest.
It is possible to make the shell do a search through the contents of the current directory, or, if used with grep, the contents of a file or standard input.
					This is usually done with a wildcard, *:
pauls-*
This will match any string that begins with the text pauls-, such as pauls-tutorials.
It is possible to take the output of a command and use it as the input for another. This is known as piping, and is accomplished with the pipe |.
ls | less
This redirects the output of the ls command and writes it to less's standard input.
					For those who know C++, this is like taking the cout of one program and giving it as cin for another.
When you're using the commandline, you will also want to know some of the basic features of the shell you're using.
These commands only work in bash! Do not try to use them in cmd!
For these commands, if you want to look them up, omit the git- prefix, since they're not actually git commands.
/.
					You can also change directories using absolute paths (from the root of the drive), by prefixing a / to the beginning of the file path.
					Under most Windows implementations, the root of the C: drive is /c/ (and /d/ for D:, /e/ for E:, etc.).cd does not have man page. Its only function is to switch directories as described here.ls will put spaces here):
							permissions | number of items (always 1 if it's a file) | user | group | size | last modified (3 fields) | filename
1k instead of 1024). To be used with -lgrep searches through standard input for a given expression and writes the result to standard output.
					Or, if a second argument is passed, search through the file passed as the second argument for the search query given in the first.|:
					$ ls -l | grep myfile
-rw-r--r-- 1 pt users 0 Aug 30 13:20 myfile.txt
mv will instead rename the file or folder as the second argument.-r switch before the rest of your arguments!-r switch before your arguments!rm is a permanent deletion. It does not send files to the recycle bin.less.less reads from standard input./, typing your search key, and hitting Enter. Use n to jump to the next result.q to quit.less. Use vi instead.vi for commit messages.
					Some useful vi commands (these must be run from outside of edit mode):vi cheat sheet
					vi is usually provided in Windows bash implementations.less.These are many of git's own commands, which follow the root git command. If you want to look up a particular command's manual, you need to add the git- prefix to the command.
To see an exhaustive list of git commands, see man git.
origin set up to refer to the cloned URI.rm, git rm will delete a file, but also removes them from the index.
	  				Normally, using normal rm will also make git see the change and remove it from the index anyway, but git rm adds some new features for dealing specifically with the git repository:
	  				-r switch.vi) to write a commit message, then commits everything in the staging area with the commit message.
  					Aborts committing if no commit message is present.
	  				git add -u followed by a git commit.message. Make sure that message is enclosed in quotes.less.git push <remote> <refspec>where
remote is the name of the remote repository and refspec is, under most circumstances, the name of the branch you wish to push to.git pull <remote> <refspec>where
remote is the name of the remote repository and refspec is, under most circumstances, the name of the branch you wish to pull from.git fetch <remote> <refspec>where
remote is the name of the remote repository and refspec is, under most circumstances, the name of the branch you wish to fetch.HEAD.
					With two arguments, it creates a new branch named according to the first argument from the reference (branch, commit, or tag) given as the second argument.
					When creating a branch, this does not automatically switch to the new branch.
					branch.branch to new-name. If a branch name is not present (only one argument), then rename the current branch to new-nameHEAD — When used with a branch or a tag, this makes the working directory reflect the HEAD of the specified branch or tag.
					Any commits made when checked out as a branch will be made to the checked-out branch.
					When used with a commit, this detaches HEAD and makes the working tree reflect the specified commit.
					Any commits made while in this state will be thrown out upon checkout of another reference unless a new branch is made from the detached HEAD.
					new-branch and check it out. If source is present, then create the branch from there instead of the current HEAD.theircopy.
mycopy.
mergetool will ask which version you wish to use.git mergetool will NOT launch the merge tool due to a program rename.
						Use the graphical method instead.git branch to create the tag from a reference other than HEAD.
					When creating a tag, you should always use the -a option and leave a tag message (much like a commit message).HEAD in less.
					Alternatively, you can view a diff between arbitrary commits by passing the commit hashes (or a HEAD reference) as arguments.git diff > diff.patch
man git-apply for more details.feature.setting as the first argument, and the setting's contents as the second argument. Some useful settings:
					cache, this will make git store your password for 15 minutes after you enter it, in case you are going to be making mutiple pushes in a short time.
							This only works for command-line git.--global switch while creating or editing a setting will set the setting as default for all repositories.