{"id":41,"date":"2009-09-11T13:34:38","date_gmt":"2009-09-11T13:34:38","guid":{"rendered":"http:\/\/www.eqsim.com\/blog\/?p=41"},"modified":"2010-02-23T13:35:22","modified_gmt":"2010-02-23T13:35:22","slug":"revisiting-git-thanks-to-scott-chacon-and-o%e2%80%99reilly","status":"publish","type":"post","link":"https:\/\/www.eqsim.com\/blog\/revisiting-git-thanks-to-scott-chacon-and-o%e2%80%99reilly\/","title":{"rendered":"Revisiting Git thanks to Scott Chacon and O\u2019Reilly"},"content":{"rendered":"<p>I just watched Scott Chacon\u2019s excellent video introduction to basic Git functionality: <a href=\"http:\/\/video.linuxfoundation.org\/video\/1516\">http:\/\/video.linuxfoundation.org\/video\/1516<\/a>.\u00a0 The audio was a bit tough to take, but it was free, and the content was so good that the audio didn\u2019t bother me too much.\u00a0 There are many excellent resources on git-scm.org, home of Git, but for whatever reason I didn\u2019t find anything as straightforward as what Scott has done.\u00a0 Admittedly, I probably didn\u2019t try to hard, rather I just dove in and then became confused.\u00a0 The video introduces a bunch of concepts along with the commands, and that helped a lot in terms of orienatation to functionality.<\/p>\n<p>To help me in the future, I made a list of the various commands I think I will be using once I get more into modifying the code of my projects that are now in repositories.\u00a0 Sorry for the brief explanations but perhaps the list can be useful to you as well (and I\u2019m nervous about just leaving it on my hard drive and then forgetting where I put it, not that that ever happens to me !).<\/p>\n<p>git clone &lt;git repo&gt; \u2013 creates a git repo in current directory from the git repo id. If you clone, creates a remote called origin by default<br \/>\ngit init \u2013 creates a new git repo in the current directory<\/p>\n<p>git branch &lt;new branch&gt;<br \/>\ngit checkout &lt;branch&gt; \u2013 switch to branch<br \/>\ngit checkout -b &lt;branch&gt; \u2013 creates new branch and switches to it<br \/>\ngit branch -v \u2013 shows last commit on each branch<\/p>\n<p>gitk \u2013 visually shows branches<br \/>\ngitk \u2013all<\/p>\n<p>git commit -am \u2018commit message here\u2019 \u2013 does staging and committing in one shot<br \/>\ngit add file \u2013 adds file to repo, or stages it if already there<\/p>\n<p>git status \u2013 shows status of current repo<br \/>\ngit log \u2013 shows log of commits<br \/>\ngit diff \u2013 what changed between last commit and current<br \/>\ngit add \u2013p<\/p>\n<p>git config \u2013global &lt;x&gt; (for changing global values)<br \/>\ngit config \u2013list (for listing environment values)<\/p>\n<p>git merge &lt;branch&gt; \u2013 Merges branch with current branch<br \/>\ngit branch -d &lt;branch&gt; \u2013 removes a branch<\/p>\n<p>git branch &lt;new branch&gt; &lt;old branch&gt; \u2013 creates a branch from old branch. You can use id from git log as old branch to identify branch point<\/p>\n<p>git remote add &lt;remote name&gt; &lt;remote code&gt; \u2013 specifies a new remote location given by name and code<br \/>\ngit push &lt;remote name&gt; &lt;branch name&gt; \u2013 pushes the branch to the remote location<br \/>\ngit remote -v \u2013 lists the remotes for the repo<br \/>\ngit fetch &lt;origin&gt; \u2013 gets the repo from the origin (remote) as a local branch (not override, like pull)<\/p>\n<p>git log &lt;branch&gt; \u2013not &lt;other branch&gt; \u2013 show a log of what is in branch but not in other branch<br \/>\ngit log \u2013stat &lt;branch&gt; \u2013not &lt;other branch&gt; \u2013 shows log of specific lines in changes<\/p>\n<p>git blame \u2013 lets you see who modified a line last<\/p>\n<p>git bisect \u2013 awesome tool to help figure out where error introduced<br \/>\ngit bisect good &lt;commit point sha&gt; \u2013 that point it was good<br \/>\ngit bisect reset \u2013 resets to where you were before bisect process<br \/>\ngit bisect bad \u2013 current point was bad<br \/>\ngit bisect start \u2013 starts bisect by checking out middle commit, which you can test and then say good or bad<\/p>\n<p>[<strong>Update<\/strong>: this wasn&#8217;t part of the video, but a very useful command for people like me who rush to commit only after realizing I forgot to add a new file: git reset &#8211;soft HEAD^ &#8211; undoes the most recent commit, ready for me to add the right files and re-commit]<\/p>\n<p>I also found this great resource from github.com: <a href=\"http:\/\/learn.github.com\/\">http:\/\/learn.github.com\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just watched Scott Chacon\u2019s excellent video introduction to basic Git functionality: http:\/\/video.linuxfoundation.org\/video\/1516.\u00a0 The audio was a bit tough to take, but it was free, and the content was so good that the audio didn\u2019t bother me too much.\u00a0 There are many excellent resources on git-scm.org, home of Git, but for whatever reason I didn\u2019t\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.eqsim.com\/blog\/revisiting-git-thanks-to-scott-chacon-and-o%e2%80%99reilly\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/posts\/41"}],"collection":[{"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":1,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":42,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/posts\/41\/revisions\/42"}],"wp:attachment":[{"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}