Git/hacks: Difference between revisions

From Freephile Wiki
< Git
Created page with "See all the changes in color, but without any context lines, and without the leading +/-/<nowiki>[space]</nowiki> This makes it easy to grab changes and stuff them in another..."
 
adds a couple example commands
Line 4: Line 4:
git diff -U0 --color myfile | sed -r "s/^([^-+ ]*)[-+ ]/\\1/"
git diff -U0 --color myfile | sed -r "s/^([^-+ ]*)[-+ ]/\\1/"
</source>
</source>
You forgot to add a file to the last commit?  Just add it to the index, and commit with <code>--amend</code>.  If you leave off the -m (message) option in the new commit, it will let you re-use the last commit message.  This lets you "undo the last commit" and redo it right.  You usually do not want to amend a commit if you've already pushed it to other repos, but if it's just local <code>--amend</code> is awesome-sauce.
<source lang="bash">
git add forgotten.php
git commit --amend
git log --stat
</source>
What's the commit history?  <code>--stat</code> gives a nice view of what happened in the log.
<source lang="bash">
git log --stat
</source>


[[Category:Development]]
[[Category:Development]]

Revision as of 10:13, 23 July 2015

See all the changes in color, but without any context lines, and without the leading +/-/[space] This makes it easy to grab changes and stuff them in another file for example.

git diff -U0 --color myfile | sed -r "s/^([^-+ ]*)[-+ ]/\\1/"


You forgot to add a file to the last commit? Just add it to the index, and commit with --amend. If you leave off the -m (message) option in the new commit, it will let you re-use the last commit message. This lets you "undo the last commit" and redo it right. You usually do not want to amend a commit if you've already pushed it to other repos, but if it's just local --amend is awesome-sauce.

git add forgotten.php
git commit --amend
git log --stat

What's the commit history? --stat gives a nice view of what happened in the log.

git log --stat