version control - Teach me git commit -
i don’t understand git commit @ all.
it’s been week since i’ve been using git , these git –a, -m, new files, untracked etc making me totally confused. tortoisegit saving me moment, understand essence , use in way it’s totally easy.
when in git command line, it’s rather difficult selectively commit files , keep rest commit. how make easy?
it quite simple. need add changes want the index first:
git add file1 file2 then
git commit if removed file, add that. add means "add change" though removal.
if want add changes:
git add -a the -a parameter on commit says add changes of tracked files , commit them. so
git commit -a will not commit new file created. must explicitly add this.
the -m parameter allows avoid opening editor edit commit message , use put in following -m option:
git commit -m "use message , don't open editor" sometimes not idea. if tried merge , had conflicts, git caches nice message once resolve conflicts , commit. there git commit better.
to selectively add files, use patch modifier on git add:
git add -p this prompt files. quite powerful can specify parts of files, or alternatively edit want add index. git commit add those.
if want gui not tortoisegit (avoid windows shell integration), use git gui.
here diagram explaining the index (or staged files):

(from http://progit.org/book/ch2-2.html)
hope helps.
Comments
Post a Comment