{"id":4917,"date":"2011-12-30T01:17:54","date_gmt":"2011-12-29T19:47:54","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=4917"},"modified":"2016-12-19T14:36:46","modified_gmt":"2016-12-19T09:06:46","slug":"creating-git-alias","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/creating-git-alias\/","title":{"rendered":"Creating GIT Alias"},"content":{"rendered":"<p>Since Git is awesome. It also provides functionality of making aliases.<br \/>\nExample<\/p>\n<p>[shell]git config &#8211;global alias.co checkout [\/shell]<\/p>\n<p>Here we created co as an alias for checkout (All the aliases that are created goes into .gitconfig file under home folder). Now to checkout a branch named testBranch, We can also write<\/p>\n<p>[shell]git co testBranch<br \/>\nSwitched to branch &#8216;testBranch'[\/shell]<\/p>\n<p>Here are couple of interesting git aliases that we can make<\/p>\n<p>1.git config &#8211;global alias.undo &#8216;reset \u2013hard&#8217;<\/p>\n<p style=\"padding-left: 30px\">Now if we write  \u201cgit undo\u201d then any of changes after my last commit will be removed.<\/p>\n<blockquote>\n<p style=\"padding-left: 30px\">\n<\/blockquote>\n<p>2.git config &#8211;global alias.cleanup = ! git fsck &amp;&amp; git  prune &amp;&amp; git gc<\/p>\n<p style=\"padding-left: 30px\">In this Command we have used exclamation mark (!), this indicates that these commands would be running on terminal.<br \/>\nAnd in git if I want multiple command to be running one after another we use double ampersand (&amp;&amp;) (We cannot use semicolon as we would usually do in terminal).<br \/>\nThis command will run git fsck (file check), git  prune (to clean dangling commits\/blobs)  and git garage collection<\/p>\n<p>Number of git alias that can be made are endless all it needs is little creativity.<\/p>\n<div>_________________________________<\/div>\n<div>Hitesh Bhatia<br \/>\nMail,LinkedIn,<a href=\"http:\/\/www.facebook.com\/home.php?#%21\/profile.php?id=100000114437286\" target=\"_blank\">Facebook<\/a>,<a href=\"http:\/\/twitter.com\/d1_ricky\" target=\"_blank\">Twitter<\/a><br \/>\n_________________________________<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Since Git is awesome. It also provides functionality of making aliases. Example [shell]git config &#8211;global alias.co checkout [\/shell] Here we created co as an alias for checkout (All the aliases that are created goes into .gitconfig file under home folder). Now to checkout a branch named testBranch, We can also write [shell]git co testBranch Switched [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[7],"tags":[741,737,739,375,742,738,743],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/4917"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=4917"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/4917\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=4917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=4917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=4917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}