git config --global user.name "Ben Peachey"
git config --global user.email "[email protected]"
2005
v2.19.1
1233
GPLv2
Linux | MacOS | Windows | |
---|---|---|---|
Popular | BASH | Terminal | PowerShell |
Alternative | zsh | iTerm2 | Git for Windows |
bash command
Content of the "filename.ext" file.
parameter(s) for git command
https://link.to/more#information
git checkout -
https://git-scm.com/docs/git-checkout#git-checkout-ltbranchgt
git config --list --global
user.name=Ben Peachey
[email protected]
git config --edit
[user]
name = Ben Peachey
email = [email protected]
https://git-scm.com/docs/git-config
[include]
path = /path/to/foo.inc
include.path /path/to/foo.inc
https://git-scm.com/docs/git-config#_includes
[include]
path = ~/.gitconfig-alias
path = ~/.gitconfig-user
Include for all repositories inside $HOME/to/group
[includeIf "gitdir:~/to/group/"]
path = /path/to/foo.inc
includeIf.gitdir:~/to/group/ /path/to/foo.inc
https://git-scm.com/docs/git-config#_includes
git help
https://git-scm.com/docs/git-help
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
available git commands in '/usr/lib/git-core'
add merge-one-file
add--interactive merge-ours
am merge-recursive
annotate merge-resolve
apply merge-subtree
archive merge-tree
bisect mergetool
bisect--helper mktag
blame mktree
branch mv
bundle mw
cat-file name-rev
check-attr notes
check-ignore pack-objects
check-mailmap pack-redundant
check-ref-format pack-refs
checkout patch-id
checkout-index prune
cherry prune-packed
cherry-pick pull
citool push
clean quiltimport
clone range-diff
column read-tree
commit rebase
commit-graph rebase--helper
commit-tree receive-pack
config reflog
count-objects remote
credential remote-ext
credential-cache remote-fd
credential-cache--daemon remote-ftp
credential-store remote-ftps
cvsexportcommit remote-http
cvsimport remote-https
cvsserver remote-mediawiki
daemon remote-testsvn
describe repack
diff replace
diff-files request-pull
diff-index rerere
diff-tree reset
difftool rev-list
difftool--helper rev-parse
fast-export revert
fast-import rm
fetch send-email
fetch-pack send-pack
filter-branch serve
fmt-merge-msg sh-i18n--envsubst
for-each-ref shell
format-patch shortlog
fsck show
fsck-objects show-branch
gc show-index
get-tar-commit-id show-ref
grep stage
gui stash
gui--askpass status
hash-object stripspace
help submodule
http-backend submodule--helper
http-fetch subtree
http-push svn
imap-send symbolic-ref
index-pack tag
init unpack-file
init-db unpack-objects
instaweb update-index
interpret-trailers update-ref
log update-server-info
ls-files upload-archive
ls-remote upload-pack
ls-tree var
mailinfo verify-commit
mailsplit verify-pack
merge verify-tag
merge-base web--browse
merge-file whatchanged
merge-index worktree
merge-octopus write-tree
git commands available from elsewhere on your $PATH
cherry-copy get-branch is-current out pull-request
cherry-move info l prompt
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help >command<' or 'git help >concept<'
to read about a specific subcommand or concept.
The common Git guides are:
attributes Defining attributes per path
cli Git command-line interface and conventions
core-tutorial A Git core tutorial for developers
cvs-migration Git for CVS users
diffcore Tweaking diff output
everyday A useful minimum set of commands for Everyday Git
glossary A Git Glossary
hooks Hooks used by Git
ignore Specifies intentionally untracked files to ignore
modules Defining submodule properties
namespaces Git namespaces
repository-layout Git Repository Layout
revisions Specifying revisions and ranges for Git
tutorial A tutorial introduction to Git
tutorial-2 A tutorial introduction to Git: part two
workflows An overview of recommended workflows with Git
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help >command<' or 'git help >concept<'
to read about a specific subcommand or concept.
* Requires the git-doc package to be installed
git help --web
https://git-scm.com/docs/git-help#_options
GIT-HELP(1) Git Manual GIT-HELP(1) NAME git-help - Display help information about Git SYNOPSIS git help [-a|--all] [-g|--guide] [-i|--info|-m|--man|-w|--web] [COMMAND|GUIDE] DESCRIPTION With no options and no COMMAND or GUIDE given, the synopsis of the git command and a list of the most commonly used Git commands are printed on the standard output. If the option --all or -a is given, all available commands are printed on the standard output. If the option --guide or -g is given, a list of the useful Git guides is also printed on the standard output. If a command, or a guide, is given, a manual page for that command or guide is brought up. The man program is used by default for this purpose, but this can be overridden by other options or configuration variables. Note that git --help ... is identical to git help ... because the former is internally converted into the latter. To display the git(1) man page, use git help git. This page can be displayed with git help help or git help --help OPTIONS -a, --all Prints all the available commands on the standard output. This option overrides any given command or guide name. -g, --guides Prints a list of useful guides on the standard output. This option overrides any given command or guide name. -i, --info Display manual page for the command in the info format. The info program will be used for that purpose. -m, --man Display manual page for the command in the man format. This option may be used to override a value set in the help.format configuration variable. By default the man program will be used to display the manual page, but the man.viewer configuration variable may be used to choose other display programs (see below). -w, --web Display manual page for the command in the web (HTML) format. A web browser will be used for that purpose. The web browser can be specified using the configuration variable help.browser, or web.browser if the former is not set. If none of these config variables is set, the git web--browse helper script (called by git help) will pick a suitable default. See git-web--browse(1) for more information about this.
[help]
format = web
help.format web
https://git-scm.com/docs/git-config#git-config-helpformat
[help]
browser = firefox
help.browser firefox
https://git-scm.com/docs/git-config#git-config-helpbrowser
[alias]
name = command
alias.name command
https://git-scm.com/docs/git-config#git-config-alias
[alias]
unstage = reset HEAD --
alias.unstage 'reset HEAD --'
https://git-scm.com/book/en/v2/Git-Basics-Git-AliasesIf the alias expansion is prefixed with an exclamation point, it will be treated as a shell command.
Shell commands will be executed from the top-level directory of a repository, which may not necessarily be the current directory.https://git-scm.com/docs/git-config#git-config-alias
echo "Hello!"
[alias]
hello = !echo "Hello!"
alias.hello '!echo "hello"'
git hello
Hello!
git config --list | grep 'alias.' | sort | cut -d= -f1
[alias]
alias = !git config --list | grep 'alias.' | sort | cut -d'.' -f1,
alias.alias '!git config --list | grep "alias." | sort | cut -d"." -f1,'
git alias
alias.alias
alias.hello
alias.unstage
git sta<TAB>
stage stash status
git stat<TAB>
git status --<TAB><TAB>
--ahead-behind --ignore-submodules --no-renames --short
--branch --ignored --null --show-stash
--column --long --porcelain --untracked-files
--find-renames --no-... --renames --verbose
git status --b<TAB>
git status --branch
[...]
git meh
git: 'meh' is not a git command. See 'git --help'.
Did you mean one of these?
fetch
merge
shell
[help]
autocorrect = 35
help.autoCorrect 35
https://git-scm.com/docs/git-config#git-config-helpautoCorrect
git doh
WARNING: You called a Git command named 'doh', which does not exist.
Continuing under the assumption that you meant 'show'
in 3.5 seconds automatically...
[...]
If the value of this option is negative, the corrected command will be executed immediately.
git doh
WARNING: You called a Git command named 'doh', which does not exist.
Continuing under the assumption that you meant 'show'
[...]
git meh
git: 'meh' is not a git command. See 'git --help'.
Did you mean one of these?
fetch
merge
shell
Behaves just like normal suggestion...
IgnoredFolder/*
ignored-file.txt
git status --ignored
On branch master
Your branch is up to date with 'origin/master'.
Ignored files:
(use "git add -f <file>..." to include in what will be committed)
IgnoredFolder/
ignored-file.txt
nothing to commit, working tree clean
https://git-scm.com/docs/git-status#git-status---ignoredltmodegt
### IDE ###
nbbuild # Netbeans
.idea/ # IntelliJ
.project # Eclipse
.vscode/* # VisualStudioCode
### Linux ###
*~
### macOS ###
.DS_Store
.AppleDouble
.LSOverride
._*
### Windows ###
Thumbs.db
[Dd]esktop.ini
### WHO KNOWS WHAT ELSE ... ###
Global / Repository / Local
Global Exclude File |
Repository Ignore File |
Local Exclude File |
---|---|---|
This machines only | This machines only | |
This repo only | This repo only | |
Committed | ||
Configurable | Configurable |
[core]
excludesfile = ~/.gitignore
core.excludesfile ~/.gitignore
https://git-scm.com/docs/git-config/#git-config-coreexcludesFileGlobal / Repository / Local
git branch --verbose
* master f44599481 [ahead 2] Last commit message on master.
develop 4563a0d9d [behind 35] The last commit message on develop.
other 260071fdb Last commit message of the other branch.
Shows which branches are ahead/behind
git log @{upstream}..
commit f44599481cc692ed78b8f14db2c6b66671daaee2 (HEAD -> master)
[...]
git log --branches --not --remotes
commit f44599481cc692ed78b8f14db2c6b66671daaee2 (HEAD -> master)
[...]
commit 58c6697c7cd38bbc246e18496d23a08cc6e02ef8 (other)
[...]
[alias]
unpushed = log --branches --not --remotes
alias.unpushed 'log --branches --not --remotes'