Files
2025-11-21 17:17:42 +01:00

1.0 KiB

  • Update all Git repos in your current directory
    • ls | xargs -I{} git -C {} pull
  • Pull from remote overwriting local changes.
    • git stash (revert and stash changes locally)
    • git pull (pull from remote normally)
    • TIP: To retrieve changes, do git stash apply
  • Delete only untracked files from working tree
    • git clean -f -d
  • Unstage files from index (but keep the files locally)
    • git rm --cached
  • Undo a merge
    • git checkout branch-name
    • git log --oneline
    • git revert -m commit-id
  • Remove a file from remote
    • git rm filename (remove file from git)
    • git commit -m "commit message"
    • git push
  • Undo last "n" commits
    • git reset --soft HEAD^n
  • See diff between branches
    • git diff branch_1..branch_2
  • Remove a tag from branch
    • git push origin :refs/tags/tagname
    • git tag -d
  • Rename a branch locally and remote
    • git checkout old-branch
    • git branch -m new-name
    • git push origin :old-name new-name
  • Move existing, uncommitted work to a new branch
    • git switch -c <new-branch>