Skip to content

Initial git setup

Craig P. Motlin edited this page May 20, 2016 · 2 revisions

First-Time Git Setup

https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup

# Your name, however you'd like it to appear
git config --global user.name "John Doe"
# Your email address, exactly matching the one used to sign the Eclipse CLA
git config --global user.email johndoe@example.com

# Replace vim with your favorite editor
git config --global core.editor vim

Git aliases

https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases

Very common aliases

git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch

Somewhat common aliases

git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
git config --global alias.cp 'cherry-pick'

Craig's aliases

git config --global alias.ss 'status -s'
git config --global alias.ri 'rebase --interactive --autosquash'
git config --global alias.l 'log --oneline --graph --decorate --all'
git config --global alias.ll 'log --oneline --graph --decorate'
git config --global alias.f 'fetch --all --prune'

git config --global alias.gl "log --graph --decorate --date=short --format=format:'%C(yellow)%h%C(reset) %C(blue)%ad%C(reset)%C(auto)%d%C(reset) %C(normal)%s%C(reset) %C(magenta)%an%C(reset)'"
git config --global alias.ga "log --graph --decorate --date=short --format=format:'%C(yellow)%h%C(reset) %C(blue)%ad%C(reset)%C(auto)%d%C(reset) %C(normal)%s%C(reset) %C(magenta)%an%C(reset)' --all"
git config --global alias.l "log --graph --decorate --date=short --format=format:'%C(yellow)%h%C(reset) %C(blue)%ad%C(reset)%C(auto)%d%C(reset) %C(normal)%s%C(reset) %C(magenta)%an%C(reset)' --all"
git config --global alias.gb "log --graph --decorate --date=short --format=format:'%C(yellow)%h%C(reset) %C(blue)%ad%C(reset)%C(auto)%d%C(reset) %C(normal)%s%C(reset) %C(magenta)%an%C(reset)' --branches"
git config --global alias.m 'mergetool --no-prompt --tool=vimdiff'
git config --global alias.detach 'checkout --detach'

Branch settings

git config --global branch.autosetuprebase always
git config --global branch.autosetupmerge always
git config --global push.default simple

Reuse recorded resolution of conflicted merges

git config --global rerere.enabled true

Fork and clone

https://github.com/eclipse/eclipse-collections

Click fork

git clone https://github.com/<username>/eclipse-collections
git config remote.pushdefault origin
git config push.default current

In your fork

git remote add upstream git@github.com:eclipse/eclipse-collections.git
git fetch --all

Fetching pull requests

If you want to fetch pull request commits locally before they are pulled, edit .git/config to add this last line to the upstream section.

[remote "upstream"]
	url = https://github.com/eclipse/eclipse-collections.git
	fetch = +refs/heads/*:refs/remotes/upstream/*
	fetch = +refs/pull/*:refs/remotes/upstream/pr/*