Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
blog:2023:10:12:git-alias [2023-10-12] – created dcaiblog:2023:10:12:git-alias [2024-12-16] (current) dcai
Line 1: Line 1:
-====== Some handy git aliases I use all the time  ======+====== git aliases I use all the time  ======
  
  
 ==== 1. choose branch to check out from fzf ==== ==== 1. choose branch to check out from fzf ====
  
-'''fzf''' is such a great tool, it changes the way how I operate in vim and shell, git checkout autocomplate with branch is great, but it's better to list branches in a menu then choose it, therefore I add below to git config file:+''fzf'' is such a great tool, it changes the way how I operate in vim and shell, git checkout autocomplate with branch is great, but it's better to list branches in a menu then choose it, therefore I add below to git config file:
  
 <code> <code>
Line 13: Line 13:
  
  
-Sometimes, I want to checkout remote branch, I use alias below, '''refname:lstrip=3''' strips the remote name from branch name ref, so git checkout could figure out and create a local branch to match it.+Sometimes, I want to checkout remote branch, I use alias below, ''refname:lstrip=3'' strips the remote name from branch name ref, so git checkout could figure out and create a local branch to match it.
  
 <code> <code>
Line 25: Line 25:
 </code> </code>
  
-The idea is list all local branches, but remove current branch (it's marked with *), pipe to fzf so user could select them by pressing '''tab''', finally pipe to git to delete.+The idea is list all local branches, but remove current branch (it's marked with *), pipe to fzf so user could select them by pressing ''tab'', finally pipe to git to delete.
  
  
Line 46: Line 46:
  
  
 +==== 5. Pick a commit, then pick changed file and open in vim ====
 +
 +<code>
 + edited-files = !git pickhash | xargs -o git show --format="format:" --name-only
 + pickfile = !git edited-files | fzf --sync | sed -e "s#^#`git rev-parse --show-toplevel`/#" | xargs -o vim
 +
 +</code>
blog/2023/10/12/git-alias.1697115081.txt.gz · Last modified: by dcai