./git/commands.txt

download original
revert local (uncommitted) changes:

git checkout HEAD -- path/to/file


unstage changes:

git reset HEAD <files>


abort a merge:

git reset --hard


clone into existing non-empty directory "foo":

git clone --bare /some/where/foo.git
mv foo.git foo/.git
cd foo
git config core.bare false
git reset HEAD .



<multi_io> is it possible to directly fast-forward a non-checked out branch to the checked out branch?
[15:23] <cehteh> git push . brach:branch
[15:24] <multi_io> i.e. I've checked out branch B, and there's a branch A in the repo which is an ancestor of B, and I want to do the equivalent of git checkout A; git merge --ff-only B; git checkout B

=> git push . B:A

<cmn> git branch -f A B would also work
<cmn> and be less magical



specifying commit ranges:

see git help rev-list

- git rev-list master: master and all commits reachable from it via "parent" relation

- git rev-list master ^other: master and all commits reachable from it, but not from other, via "parent" relation

from git help rev-list:

       You can think of this as a set operation. Commits given on the command line form a set of commits that are reachable
       from any of them, and then commits reachable from any of the ones given with ^ in front are subtracted from that set.
       The remaining commits are what comes out in the command’s output. Various other options and paths parameters can be used
       to further limit the result.

several commands take commit range arguments, e.g. cherry-pick.


directly moving HEAD pointer to any branch, without touching either
the index or the wd (essentially a checkout without modifying the
index or wd):

git symbolic-ref HEAD refs/heads/<branch>

(after which you'd probably issue a "git reset" to copy the new HEAD
tree into the index)


============

change author date AND committer date (only way I found that seems to work):

git commit --amend --date=$d
GIT_COMMITTER_DATE=$d git commit --amend

(doesn't work in one command?? --

git commit --amend --date=$d  only changes the author date, sets the committer date to now

GIT_AUTHOR_DATE=$d GIT_COMMITTER_DATE=$d  git commit --amend --date=$d only changes the committer date, sets the author date to now (WTF?)

git1.8.4.rc3
)


git 2.0.0:

setting both variables works now. e.g. GIT_AUTHOR_DATE='xxxx-xx-xxTxx:xx:xx' GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" git commit

I'm pretty sure this didn't work in 1.8, but whatever.

(git 2.1.3, OSX) the above doesn't work, but this does (sets both times):

(d='2015-01-13T22:08:09'; EDITOR=vim GIT_AUTHOR_DATE="$d" GIT_COMMITTER_DATE="$d" git commit --date="$d")

(not sure which of the values is actually needed. Without the --date
option, notthing is set, with --date but without the environment --
probably only the author time)



get useful description of current HEAD, even if detached and/or dirty:

git describe --tags --dirty

  
back to git

(C) 1998-2017 Olaf Klischat <olaf.klischat@gmail.com>