Joined February 2012
·

Julien Carsique

DevOps at Nuxeo
DevOps
Nuxeo
·
Paris, France
·
·
·

Posted to Git autosquash goodies over 1 year ago

I don't see the point of fixprev and sqprev since they are equivalent to git commit --amend [--no-edit]

I wrote an alias leveraging those --fixup and --autosquash options: https://gist.github.com/jcarsique/24f8dd46d176bb67253e

I use it every day combined with git add -p to separate the fommatting and cleanup changes from the important code changes, or to distribute the changes on the relevant commits.

Worth to mention that this command changes the Git history: to be used on a local or "feature" branch.

fix = "!_() { c=$(git rev-parse $1) && git commit --fixup $c && git diff-index --quiet HEAD; s=$?; [ $s != 0 ] && git stash; git -c core.editor=cat rebase -i --autosquash --keep-empty $c~ && [ $s != 0 ] && git stash pop; }; _"

Simplified since Git 1.8.4 with --autostash:

fix = "!_() { c=$(git rev-parse $1) && git commit --fixup $c && git -c core.editor=cat rebase -i --autosquash --keep-empty --autostash $c~; }; _"

Usage:

git add ... # stage changes to fix up

git fix <rev>

That will temporarily stash the current changes if any and fixup the given revision with the staged changes.

Posted to .gitexcludes over 1 year ago

https://github.com/github/gitignore provides a whole bunch of sample ignore files.

For instance:

cd $HOME/workspace/
git clone https://github.com/github/gitignore.git
git config --global core.excludesfile $HOME/workspace/gitignore/Global/Eclipse.gitignore
Posted to "git status" without untracked files over 1 year ago

That may be very occasionally useful but I cannot see any good reason to often have untracked files not excluded by .gitignore. As said above, developers already happen to forget files in their commits, such an option will get it worse.

Posted to A better git log over 1 year ago

As of Git 1.8.3 (May 24, 2013), you can now have (automatic) more comprehensive and useful colors on commits, branches and tags using %C(auto):

git log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
Posted to A better git log over 1 year ago

As of Git 1.8.3 (May 24, 2013), you can now have (automatic) more comprehensive and useful colors on commits, branches and tags using %C(auto):

git log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
Posted to A better git log over 1 year ago

As of Git 1.8.3 (May 24, 2013), you can now have (automatic) more comprehensive and useful colors on commits, branches and tags using %C(auto):

git log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

As of git 1.8.3 (May 24, 2013), add %C(auto) to colorize the output:

$ git config --global alias.id "show -s --pretty=format:'%C(auto)%h%d'"
Posted to WTF did I do?! over 1 year ago

Nice. Here's a slightly changed @jacaetevha version with colors, recursion and author output option removed:
https://gist.github.com/jcarsique/5958214

Great use of --fixup and --autosquash options!

However, it will fail on Shells which don't have the <<< redirection operator (such as dash).
It is possible to detect if stash is required using diff-index instead of grep:

fix = "!_() { c=$(git rev-parse $1) && git commit --fixup $c && git diff-index --quiet HEAD; s=$?; [ $s != 0 ] && git stash; git -c core.editor=cat rebase -i --autosquash $c~; [ $s != 0 ] && git stash pop; }; _"

Thanks, your alias is really useful.

Also, for Firefox 17+, open about:config and set:

  • general.autoScroll = true
  • mousewheel.with_shift.action = 1
  • optionally configure the scroll speed with mousewheel.with_shift.delta_multiplier_x = 300
Posted to Find Your Most Prolific Contributors over 1 year ago

Great. Here is as a Git alias:
authorship = "!git ls-files -z|xargs -0 -n1 -E'\n' -J {} git blame --date short -wCMcp '{}'| perl -pe 's/^.?\((.?) +\d{4}-\d{2}-\d{2} +\d+\).*/\1/'| sort | uniq -c | sort -rn"

Achievements
158 Karma
6,568 Total ProTip Views