| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Часто используемые трюки и советы при работе с Git.
Хотите дополнить список? Ознакомьтесь с contributing.md
P.S: Все эти команды были проверены в git version 2.7.4 (Apple Git-66)
git checkout -b <branch-name>Alternatives:
git branch <branch-name> && git checkout <branch-name>git checkout -git branch -agit branch -rgit branch -vvgit branch -m <new-branch-name>Alternatives:
git branch -m [<old-branch-name>] <new-branch-name>git branch -d <local_branchname>git push origin --delete <remote_branchname>Alternatives:
git push origin :<remote_branchname>git branch --merged mastergit branch --merged master | grep -v '^\*' | xargs -n 1 git branch -dAlternatives:
git branch --merged master | grep -v '^\*\| master' | xargs -n 1 git branch -d # will not delete master if master is not checked outgit branch -a --contains <commit-ish>Alternatives:
git branch --contains <commit-ish>git branch -u origin/mybranchgit commit --amendgit commit --amend --no-editgit commit --amend --no-edit --author='Author Name <email@address.com>'git commit --amend --reset-author --no-editgit commit --only <file_path>git commit --no-verifygit commit --fixup <SHA-1>git config --listgit config [--global] --editgit config --global core.editor '$EDITOR'git config core.fileMode falsegit config --global core.ignorecase falsegit config --global help.autocorrect 1git config --global color.ui falsegit config --global <specific command e.g branch, diff> <true, false or always>git config --global --unset <entry-name>git config --global rerere.enabled 1git config --global pull.rebase trueAlternatives:
#git < 1.7.9
git config --global branch.autosetuprebase alwaysgit config --global alias.<handle> <command>
git config --global alias.st statusgit diffgit diff HEADgit diff --cachedAlternatives:
git diff --stagedgit diff --word-diffgit diff --name-only --diff-filter=Ugit diff --name-only | uniq | xargs $EDITORgit diff-tree --no-commit-id --name-only -r <commit-ish>git log --since='FEB 1 2017' --until='FEB 14 2017'git shortloggit log --perl-regexp --author='^((?!excluded-author-regex).*)
git log --follow -p -- <file_path>git log --first-parentgit log --branches --not --remotesAlternatives:
git log @{u}..git cherry -vgit log --no-merges --stat --reverse master..git log Branch1 ^Branch2git log --show-signaturegit log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s
", add, subs, loc }' -Alternatives:
git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s, removed lines: %s, total lines: %s
", add, subs, loc }' - # on Mac OSXgit log --all --grep='<given-text>'git log --show-notes='*'git log --pretty=oneline --graph --decorate --allAlternatives:
gitk --allgit log master..<branch-name> --oneline | tail -1git stashAlternatives:
git stash savegit stash save -uAlternatives:
git stash save --include-untrackedgit stash listgit stash popAlternatives:
git stash apply stash@{0} && git stash drop stash@{0}git stash apply <stash@{n}>git stash clearAlternatives:
git stash drop <stash@{n}>git tag -d <tag-name>git push origin :refs/tags/<tag-name>git help everydaygit help -ggit clone -b <branch-name> --single-branch https://github.com/user/repo.gitgit clone https://github.com/user/repo.git --depth 1git clone repo.bundle <repo-dir> -b <branch-name>git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'git fetch --all && git reset --hard origin/mastergit fetch -pAlternatives:
git remote prune origingit fetch origin pull/<id>/head:<branch-name>Alternatives:
git pull origin pull/<id>/head:<branch-name>git fetch origin master:refs/remotes/origin/mymastergit ls-tree --name-only -r <commit-ish>git update-ref -d HEADgit describe --tags --abbrev=0git revert <commit-ish>git revert -m 1 <commit-ish>git reset <commit-ish>git reset HEAD <file-name>git cherry -v mastergit remoteAlternatives:
git remote showgit remote set-url origin <URL>git ls-remote git://git.kernel.org/pub/scm/git/git.gitgit remote add <remote-nickname> <remote-url>git add -pcurl http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrcgit log --no-merges --raw --since='2 weeks ago'Alternatives:
git whatchanged --since='2 weeks ago'git checkout <branch-name> && git cherry-pick <commit-ish>git checkout <stash@{n}> -- <file_path>Alternatives:
git checkout stash@{0} -- <file_path>git checkout -- <file_name>git checkout --orphan <branch_name>git checkout master && git branch --no-mergedgit ls-files -tgit ls-files --othersgit ls-files --others -i --exclude-standardgit worktree add -b <branch-name> <path> <start-point>git worktree add --detach <path> HEADgit rm --cached <file_path>Alternatives:
git rm --cached -r <directory_path>git clean -ngit clean -fgit clean -f -dAlternatives:
git clean -dfgit submodule foreach git pullAlternatives:
git submodule update --init --recursivegit submodule update --remotegit cherry -v masterAlternatives:
git cherry -v master <branch-to-be-merged>git rebase master feature && git checkout master && git merge -git archive master --format=zip --output=master.zip git rev-list --reverse HEAD | head -1Alternatives:
git rev-list --max-parents=0 HEADgit log --pretty=oneline | tail -1 | cut -c 1-40git log --pretty=oneline --reverse | head -1 | cut -c 1-40git subtree push --prefix subfolder_name origin gh-pagesgit subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git mastergit subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git mastergit bundle create <file> <branch-name>git rev-parse --abbrev-ref HEADgit update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changeloggit rebase --autostashgit difftool -t <commit1> <commit2> <path>git update-index --assume-unchanged <file_name>git update-index --no-assume-unchanged <file_name>git clean -X -fgit checkout <deleting_commit>^ -- <file_path>git checkout <commit-ish> -- <file_path>git name-rev --name-only <SHA-1>git clean -fd --dry-rungit rebase -i --autosquashgit add -igit check-ignore *git status --ignoredgit count-objects --human-readablegit gc --prune=now --aggressivegit instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]git show <branch_name>:<file_name>git rebase --interactive HEAD~2git bisect start # Search start
git bisect bad # Set point to bad commit
git bisect good v2.6.13-rc2 # Set point to good commit|tag
git bisect bad # Say current state is bad
git bisect good # Say current state is good
git bisect reset # Finish search
git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/git grep --heading --line-number 'foo bar'git push -f <remote-name> <branch-name>git push --force-with-lease <remote-name> <branch-name>git rev-list --count <branch-name>git notes add -m 'Note on the previous commit....'git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1> | git am -3 -kdiff -u <(git rev-list --first-parent BranchA) <(git rev-list --first-parent BranchB) | sed -ne 's/^ //p' | head -1git blame <file-name>git blame -L <start>,<end>git var -l | <variable>git format-patch -M upstream..topicgit rev-parse --show-toplevelgit request-pull v1.0 https://git.ko.xz/project master:for-linusgit ls-files --others -i --exclude-standard | xargs zip untracked.zip| Back | FazBrowse Home | New Git URL |