You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.9 KiB

  1. # @noroadsleft's Git aliases
  2. [Return to the directory index.](./)
  3. ```
  4. [alias]
  5. # change branches
  6. co = checkout
  7. cob = checkout -b
  8. # sync master
  9. sync = "!f() { if [ $(git branch-name) != "master" ]; then git checkout master; fi; git pull upstream master; git push origin master; }; f"
  10. # Return the last five commits on the branch, in a more compact format
  11. hist = log --pretty=format:\"%C(yellow)%h%Creset %Cgreen%ad%Creset%n %w(100,0,3)%s%d [%an]%n\" --graph --date=iso-local -n 5
  12. histm = log --pretty=format:\"%C(yellow)%h%Creset %w(100,0,3)%s%d [%an]\" --graph --date=iso-local -n 5
  13. histt = log --pretty=format:\"%C(yellow)%h%Creset %<(88,trunc)%s [%an]\" --graph --date=iso-local -n 5
  14. histb = log --reverse --pretty=format:\"- %<(98,trunc)%s [%an]\" --date=iso-local -n 5
  15. # compact diff
  16. df = "diff --compact-summary"
  17. # Short-form status
  18. st = "!git status --short"
  19. # Returns the name of the current branch
  20. branch-name = "!git rev-parse --abbrev-ref HEAD"
  21. # short-form of the above
  22. bn = "!git branch-name"
  23. po = "push origin ($(git branch-name))"
  24. # List the stashes
  25. sl = "stash list"
  26. # Show the contents of a numbered stash
  27. # Syntax:
  28. # git st-show <int>
  29. st-show = "!f() { git stash show stash@{$1} -p; }; f"
  30. # Apply a stash, without deleting it from the list of stashes
  31. # Syntax:
  32. # git st-copy <int>
  33. st-copy = "!f() { git stash apply stash@{$1}; }; f"
  34. # Unstage a file
  35. unstage = "reset HEAD"
  36. # Restore a file to the state it was in when checked out
  37. restore = "checkout --"
  38. # Compare local master repo to its upstream branch. If anything is returned, local branch has diverged from upstream.
  39. cm = "!f() { git fetch upstream master; git diff $(git branch-name) upstream/master --compact-summary; }; f"
  40. cml = "!f() { git fetch upstream master; git diff $(git branch-name) upstream/master; }; f"
  41. ```