GIT Command Line
The Git Command Line:
Git is simple to use, type git. Without any arguments, Git lists options and the most common subcommands:
$ git
git [--version] [--exec-path[=GIT_EXEC_PATH]]
[-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR]
[--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]
The most commonly used git commands are:
add Add file contents to the index
bisect Find the change that introduced a bug by binary search
branch List, create, or delete branches
checkout Checkout and switch to a branch
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, the commit and working trees, etc.
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories
mv Move or rename a file, a directory, or a symlink
pull Fetch from and merge with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete, or verify a tag object signed with GPG
For a complete (and somewhat daunting) list of git subcommands, type git help --all.
To check Version:
$ git --version
git version 1.6.0
In contrast, --amend is an example of an option specific to the git subcommand commit:
Git commands understand both “short” and “long” options. For example, the git commit command treats the following examples as equivalents:
$ git commit -m "Fixed typo."
$ git commit --message="Fixed typo."
The short form, -m, uses a single hyphen, whereas the long form, --message, uses two.
Some options exist only in one form.
u can separate options from a list of arguments via the “bare double dash” convention. For instance, use the double dash to contrast the control portion of the
command line from a list of operands, such as filenames:
$ git diff -w master origin -- tools/Makefile
You may need to use the double dash to separate and explicitly identify filenames if they might otherwise be mistaken for another part of the command.
For example, if you happened to have both a file and a tag named main.ttt, you would get different behavior:
# Checkout the tag named "main.ttt"
$ git checkout main.ttt
# Checkout the file named "main.ttt"
$ git checkout -- main.ttt
Comments
Post a Comment