git-tips / tips
- суббота, 4 июня 2016 г. в 03:13:07
JavaScript
Most commonly used git tips and tricks.
Collection of
git-tips, want to add your tips? Checkout contributing.md
master branch.gitignore.git help everydaygit help -ggit fetch --all && git reset --hard origin/mastergit ls-tree --name-only -r <commit-ish>git update-ref -d HEADgit diff --name-only --diff-filter=Ugit diff-tree --no-commit-id --name-only -r <commit-ish>git diffgit diff --cachedgit diff HEADgit checkout master && git branch --mergedgit checkout -git branch --merged | grep -v '\*' | xargs -n 1 git branch -dgit branch -vvgit branch -u origin/mybranchgit branch -d <local_branchname>git push origin --delete <remote_branchname>Alternatives:
git push origin :<remote_branchname>git checkout -- <file_name>git revert <commit-ish>git reset <commit-ish>git commit -v --amendgit commit --amend --author='Author Name <email@address.com>'git commit --amend --reset-author --no-editgit remote set-url origin <URL>git remoteAlternatives:
git remote showgit branch -agit branch -rgit add -pcurl http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrcgit whatchanged --since='2 weeks ago'git log --no-merges --stat --reverse master..git checkout <branch-name> && git cherry-pick <commit-ish>git branch -a --contains <commit-ish>Alternatives:
git branch --contains <commit-ish>git config --global alias.<handle> <command>
git config --global alias.st statusgit stashAlternatives:
git stash savegit stash save -uAlternatives:
git stash save --include-untrackedgit stash listgit stash apply <stash@{n}>git stash popAlternatives:
git stash apply stash@{0} && git stash drop stash@{0}git stash clearAlternatives:
git stash drop <stash@{n}>git checkout <stash@{n}> -- <file_path>Alternatives:
git checkout stash@{0} -- <file_path>git 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 pullgit cherry -v masterAlternatives:
git cherry -v master <branch-to-be-merged>git branch -m <new-branch-name>Alternatives:
git branch -m [<old-branch-name>] <new-branch-name>git checkout feature && git rebase @{-1} && git checkout @{-2} && git merge @{-1}master branchgit archive master --format=zip --output=master.zipgit add --all && git commit --amend --no-editgit fetch -pAlternatives:
git remote prune origin git rev-list --reverse HEAD | head -1git log --pretty=oneline --graph --decorate --allAlternatives:
gitk --allgit 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 clone repo.bundle <repo-dir> -b <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 fetch origin pull/<id>/head:<branch-name>Alternatives:
git pull origin pull/<id>/head:<branch-name>git describe --tags --abbrev=0git diff --word-diffgit update-index --assume-unchanged <file_name>git update-index --no-assume-unchanged <file_name>.gitignore.git clean -X -fgit checkout <deleting_commit>^ -- <file_path>git checkout <commit-ish> -- <file_path>git config --global branch.autosetuprebase alwaysgit config --listgit config --global core.ignorecase falsegit config --global help.autocorrect 1git name-rev --name-only <SHA-1>git clean -fd --dry-rungit commit --fixup <SHA-1>git rebase -i --autosquashgit commit -am <commit message>git check-ignore *git status --ignoredgit log Branch1 ^Branch2git config --global rerere.enabled 1git diff --name-only | uniq | xargs $EDITORgit count-objects --human-readablegit gc --prune=now --aggressivegit instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]git log --show-signaturegit config --global --unset <entry-name>git checkout --orphan <branch_name>git diff --stagedgit show <banch_name>:<file_name>git log --first-parentgit rebase --interactive HEAD~2