docs/basic-operations.md
git ls-tree --name-only -r <commit-ish>
git checkout -
Alternatives:
git checkout @{-1}
git push origin --delete <remote_branchname>
Alternatives:
git push origin :<remote_branchname>
git branch -dr <remote/branch>
git push origin :refs/tags/<tag-name>
git checkout -- <file_name>
git commit -v --amend
git cherry -v master
git commit --amend --author='Author Name <[email protected]>'
git add -p
git checkout <branch-name> && git cherry-pick <commit-ish>
git checkout <stash@{n}> -- <file_path>
Alternatives:
git checkout stash@{0} -- <file_path>
git worktree add -b <branch-name> <path> <start-point>
git worktree add --detach <path> HEAD
git cherry -v master
Alternatives:
git cherry -v master <branch-to-be-merged>
git add --all && git commit --amend --no-edit
git fetch -p
Alternatives:
git remote prune origin
git rev-list --reverse HEAD | head -1
Alternatives:
git rev-list --max-parents=0 HEAD
git log --pretty=oneline | tail -1 | cut -c 1-40
git log --pretty=oneline --reverse | head -1 | cut -c 1-40
git clone repo.bundle <repo-dir> -b <branch-name>
git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog
git fetch origin pull/<id>/head:<branch-name>
Alternatives:
git pull origin pull/<id>/head:<branch-name>
git checkout <deleting_commit> -- <file_path>
git checkout <commit-ish> -- <file_path>
git commit --fixup <SHA-1>
git commit --only <file_path>
git add -i
git status --ignored
git checkout --orphan <branch_name>
git 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 commit --no-verify
git clone -b <branch-name> --single-branch https://github.com/user/repo.git
git checkout -b <branch-name>
Alternatives:
git branch <branch-name> && git checkout <branch-name>
git switch -c <branch-name>
git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/
git clone https://github.com/user/repo.git --depth 1
git push -f <remote-name> <branch-name>
git shortlog
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 -k
git fetch origin master:refs/remotes/origin/mymaster
git request-pull v1.0 https://git.ko.xz/project master:for-linus
git status --short --branch
git checkout master@{yesterday}
git push origin HEAD
git push -u origin <branch_name>
cd <path-to-submodule>
git pull origin <branch>
cd <root-of-your-main-project>
git add <path-to-submodule>
git commit -m "submodule updated"
git clone --bare https://github.com/exampleuser/old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git