Skip to content

Git: Stashes, tags, remotes, worktrees & submodules

12 Git commands: Stashes, tags, remotes, worktrees & submodules. Click a command to see what each part does.

Index
12 items
Click a command to see what each part does.

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 stashes

    What each part does

    1. stash listall stashes
    2. show -pthe diff of one
    3. applyre-apply but keep it (pop removes it)
    4. dropdelete it
  • git tag -l 'v1.*'; git tag -d <tag> && git push origin --delete <tag>List and delete tagsCaution

    What each part does

    1. tag -l 'v1.*'list matching tags
    2. tag -ddelete locally
    3. push origin --delete <tag>delete on the remote
  • git push --tagsPush all tags

    What each part does

    1. --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

    1. 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 once

    What each part does

    1. worktree addcheck out another branch in a second folder, sharing the same repo
    2. list / removesee and clean up worktrees
  • git clone --recurse-submodules <url>; git submodule update --init --recursiveClone with submodules / update them

    What each part does

    1. --recurse-submodulesalso clone nested repos
    2. submodule update --init --recursivefetch submodules in an existing clone
  • git ls-files | grep <pattern>Which files does git track?

    What each part does

    1. ls-filestracked files
    2. | grepfilter
  • git check-ignore -v <file>Why is this file ignored?

    What each part does

    1. check-ignore -vthe .gitignore file and line that ignores it
  • git config --list --show-originSee all config and where it comes from

    What each part does

    1. --listevery setting
    2. --show-originwhich file set it (system, global, repo)
  • git config --global alias.lg "log --oneline --graph --decorate --all"Create a git alias

    What each part does

    1. alias.lgnew command git lg
    2. "log ..."what it expands to
  • git archive --format=zip -o <file>.zip <commit-or-tag>Make a zip of a commit without .git

    What each part does

    1. git archiveexport the tracked files of that version
    2. --format=zip -ooutput format and file
  • git switch -Switch back to the previous branch

    What each part does

    1. -the branch you were on before (like cd -)

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…