Git command list, which I use infrequently enough to keep forgetting the correct syntax for.
Note
Remote name is assumed to be "origin".
git branch -d <branchname>
git push -d <remote_name> <branchname>
# --- or ---
git push <remote_name> :<branchname>
(same commands as for branch deleting)
git clone <repo> --single-branch --branch <branch> .
git ls-remote --heads origin
git fetch origin <remote-branch>:<local-branch>
git checkout <local-branch>
git remote add upstream <remote-url>
git fetch -v upstream
git remote set-url --push upstream INVALID_URL
Any nonexisting URL can be used instead of original one; it doesn't have to be literally INVALID_URL
. But AFAIK there is no way to delete the push url while keeping the pull one (or vice versa).
git clone <repo> --mirror
Note
This results in a bare repo.
git push --all
git diff --color-words <ref1> <ref2>
git diff --color-words=. <ref1> <ref2>
git diff --no-index <path1> <path2>
galya-otmena() {
# no arguments
# ! resets both index and working tree; purges untracked files
git reset --hard HEAD
git clean -d --force
}
galya-zavoz() {
# usage: galya-zavoz [<target-branch>]
# ! resets both index and working tree; purges untracked files
git fetch
git reset --hard "origin/${1:-"$(git branch --show)"}"
git clean -d --force
}
fastpush() {
# no arguments
local gitbranch=$(git rev-parse --abbrev-ref HEAD)
git push --set-upstream origin "$gitbranch"
}
autopush() {
# usage: autopush [<commit-message>]
local commitmsg="${*:-smol update}"
local gitdir=$(git rev-parse --show-toplevel) || return 1
git -C "$gitdir" add .
git commit -m "$commitmsg"
fastpush
}
Author: | Alexandr Shavykin |
---|---|
Contact: | [email protected] |
Date: | 26-Apr-25 04:31:38 PDT |