git

Configuration

.gitconfig

From my .gitconfig
  • Includes typos.
.gitconfig
1
[color]
2
diff = auto
3
status = auto
4
branch = auto
5
ui = true
6
[alias]
7
ci = commit
8
cloen = clone
9
co = checkout
10
chekcout = checkout
11
dif = diff
12
l = log
13
l1 = log -n1 -p
14
ll = log -p
15
stauts = status
Copied!

Bash

1
git config user.name "Aizat Faiz"
2
git config user.email [email protected]
Copied!

Version

Include branch in shell.
Pros:
  • You always know which branch is being worked on.

Aliases

From my .bash_profile
.bash_profile
1
alias ga='git add'
2
alias gb='git branch'
3
alias gba='git branch -a'
4
alias gau='git add -u'
5
alias gca='git commit --amend --no-edit'
6
alias gci='git commit'
7
alias gcm='git commit -m'
8
alias gco='git checkout'
9
alias gdc='git diff --cached'
10
alias gd='git diff'
11
alias gdd='git diff --name-only HEAD^ | cat'
12
alias gf='git fetch'
13
alias gfgsr='git fetch && git svn rebase'
14
alias gl='git log'
15
alias gl1='git log -n1'
16
alias gl1p='git log -n1 -p'
17
alias gll='git log -p'
18
alias gp='git pull'
19
alias gpr='git pull --rebase'
20
alias grc='git rebase --continue'
21
alias gs='git status'
22
alias gsi='git submodule init'
23
alias gsu='git submodule update'
24
alias gsr='git svn rebase'
25
alias gsrgf='git svn rebase && git fetch && git svn rebase'
26
alias gf='git diff-tree --no-commit-id --name-only -r HEAD'
Copied!

Commands

1
git diff --name-only
2
git log --graph
Copied!
Compare diff with another branch, good for flattening:
1
git diff master..branchname
2
git diff branchname..master
3
git diff master..HEAD
Copied!
Display file changes between revisions:
1
git diff --name-only HEAD^
2
git diff --name-status branchname..develop
3
git diff --name-only branchname..develop
4
git diff --name-only HEAD^ | xargs mvim -p # useful for opening in multiple tabs
5
git diff --name-only --diff-filter=d HEAD^ | xargs mvim -p # Filter to ignore deleted files
Copied!
Which tags include a particular commit:
1
git tag --contains 741326a842e8c3d443c2787980f2fe6e079ccb39
Copied!
Delete remote branch
1
git push origin :dotfiles
Copied!

Before Pushing

Squash branches as much as possible
1
git rebase -i master..
Copied!

Best Practices

Cons

  • No equivalent of hg copy

--fixup

GitHub

See GitHub

GitLab

  • Alot more tools.
    • Time Tracking, Milestones, Weight

Pros

  • Merge Requests
    • You can work on the commit message before merginging.

Cons

  • UI is sparse

Vim

Install vim-fugitive
Inside vim:
In command mode, will open a browser pointing to the file in GitHub
1
:Gbrowse
Copied!
This works when lines are highlighted as well.

Resources

Browsers

IDEs

Last modified 2yr ago