Git: Stashes, tags, remotes, worktrees & submodules
12 Git commands: Stashes, tags, remotes, worktrees & submodules. Click a command to see what each part does.
Git: Stashes, tags, remotes, worktrees & submodulesIndex
Stashes, tags, remotes, worktrees & submodules12
git stash list; git stash show -p stash@{1}; git stash apply stash@{1}; git stash drop stash@{1}List, show, apply and drop stashesWhat each part does
stash listall stashesshow -pthe diff of oneapplyre-apply but keep it (pop removes it)dropdelete it
git tag -l 'v1.*'; git tag -d <tag> && git push origin --delete <tag>List and delete tagsCautionWhat each part does
tag -l 'v1.*'list matching tagstag -ddelete locallypush origin --delete <tag>delete on the remote
git push --tagsPush all tagsWhat each part does
--tagspush every local tag (git push --follow-tags pushes only annotated ones for pushed commits)
git remote set-url origin <url>Change a remote's URL (HTTPS to SSH, moved repo)What each part does
remote set-url originpoint origin at a new URL
git worktree add ../<dir> <branch>; git worktree list; git worktree remove ../<dir>Work on two branches at onceWhat each part does
worktree addcheck out another branch in a second folder, sharing the same repolist / removesee and clean up worktrees
git clone --recurse-submodules <url>; git submodule update --init --recursiveClone with submodules / update themWhat each part does
--recurse-submodulesalso clone nested repossubmodule update --init --recursivefetch submodules in an existing clone
git ls-files | grep <pattern>Which files does git track?What each part does
ls-filestracked files| grepfilter
git check-ignore -v <file>Why is this file ignored?What each part does
check-ignore -vthe .gitignore file and line that ignores it
git config --list --show-originSee all config and where it comes fromWhat each part does
--listevery setting--show-originwhich file set it (system, global, repo)
git config --global alias.lg "log --oneline --graph --decorate --all"Create a git aliasWhat each part does
alias.lgnew command git lg"log ..."what it expands to
git archive --format=zip -o <file>.zip <commit-or-tag>Make a zip of a commit without .gitWhat each part does
git archiveexport the tracked files of that version--format=zip -ooutput format and file
git switch -Switch back to the previous branchWhat each part does
-the branch you were on before (like cd -)
Nothing matches.
My DevOps Playbook by Angelo John Calleja