selfjungle Just another WordPress weblog


git checkout pull requests

Edit .git/config :

[remote "origin"]
        url = ...
#       fetch = +refs/heads/*:refs/remotes/origin/*
        fetch = +refs/pull/*/head:refs/remotes/origin/pull/*
Tagged as: No Comments

git word diff

git diff --word-diff=color

shows changes in place.

Tagged as: No Comments

Export/apply git diff as patch

git diff > save.patch
patch -p1 < save.patch

Link: Stackoverflow

Tagged as: No Comments

git auto-completion

wget -O ~/.git-completion.bash
source ~/.git-completion.bash
Tagged as: , No Comments

pushing to a non-bare git repo

Init a directory as a bare repo in the first place:

git init . # non-bare
git init -bare . # bare

To be able to push into a non-bare repo, just check out a branch users don't push to:

git checkout -b DUMMY_BRANCH_DONT_USE

Or turn it into a bare repo:

rm *
mv .git/* .
rm .git
sed -i 's/bare = false/bare = true/' config

Source: gitolite

Tagged as: No Comments

git ignoring changes

Ignoring files in repository:

edit .gitignore
git update-index --[no-]assume-unchanged FILE # if rule was added after the tracked file

Ignoring files in all repositories on your computer:

edit ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global

Ignoring local per-repository files:

edit .git/info/exclude

Source: github help

Tagged as: No Comments

git tag

Tag commit:

git tag <tagname> -m <msg> #lightweight
git tag -a <tagname> -m <msg> #annotated, preferred

Push tags (not done by default):

git push --tags <remote> <branch> #dangerous, avoid pushing all tags!
git push  <remote>  <tagname>

Fetch tags

git fetch --tags <remote> <branch> #or
git remote update <remote> 

Look up which branch has the tag

git branch --all --contains <tagname>

delete tags remote and local:

git push --delete origin <tagname>
git tag -d  <tagname>
Tagged as: No Comments