Git from command line

I've started using git from command line a while ago, and i just can't express the ease it gave me compared to always switching between tools ( everyone else in the team is using something else ).

My main sources of learning were:

My config so far:

mergetool.meld.path=C:\Program Files (x86)\Meld\Meld.exe
difftool.meld.path=C:\Program Files (x86)\Meld\Meld.exe
alias.l=log --pretty=format:'%C(yellow)%h %C(black)\\%C(yellow) %ad%C(black)%d \\ %C(yellow)%Creset%s%C(black) \\ %C(cyan)[%cn]' --decorate --date=short --graph -30
alias.p=pull --rebase
alias.dlc=difftool --cached -d
alias.d=difftool -d
alias.s=status -s
alias.res=reset --hard
alias.ll=log --pretty=format:'%C(yellow)%h %C(black)\\%C(yellow) %ad%C(black)%d \\ %C(yellow)%Creset%s%C(black) \\ %C(cyan)[%cn]' --decorate --date=short --graph
alias.dc=!f() { git difftool -d $1^ $1; }; f

Config as you can copy to .gitconfig

    tool = meld
[mergetool "meld"]
    path = C:\\Program Files (x86)\\Meld\\Meld.exe
    tool = meld
[difftool "meld"]
    path = C:\\Program Files (x86)\\Meld\\Meld.exe
    l = log --pretty=format:'%C(yellow)%h %C(black)\\\\%C(yellow) %ad%C(black)%d \\\\ %C(yellow)%Creset%s%C(black) \\\\ %C(cyan)[%cn]' --decorate --date=short --graph -30
    p = pull --rebase
    dlc = difftool --cached -d
    d = difftool -d
    s = status -s
    res = reset --hard
    ll = log --pretty=format:'%C(yellow)%h %C(black)\\\\%C(yellow) %ad%C(black)%d \\\\ %C(yellow)%Creset%s%C(black) \\\\ %C(cyan)[%cn]' --decorate --date=short --graph
    dc = "!f() { git difftool -d $1^ $1; }; f"
    default = current


expected result
git s

displays the list of files changed in the working tree

git p pull with rebase
git ll list all the previous commits in the current branch page by page, until 'q' key
git l list the previous 30 commits in the current branch in a formatted way
git dlc show all the changes which were stashed to the next commit
git dc show the diff which in tree which was introduced in the specified commit
git d

show all the changes between the working tree and the index in difftool


General workflows

  1. Clone a repo
    • git clone <<repo url>>
    • git checkout <<branch>>

  2. Get new version
    • git p

  3. Push changes
    • git d
    • (optional: git checkout <<path>> to revert changes which are not needed)
    • git add .
    • git commit -m "<<commit message>>"
    • git p
    • (git mergetool . if needed, git rebase --continue)
    • check if solution still works (smile)
    • git push


I've created a shortcut for the current repo's location, like this:

C:\Windows\System32\cmd.exe "C:\Program Files\Git\usr\bin\bash.exe" --login -i /K "cd <<project path>>"

this way it also keeps the setting of the command line window (background, font, size, etc)

Add comment