{"id":601,"date":"2012-12-15T18:25:08","date_gmt":"2012-12-15T18:25:08","guid":{"rendered":"http:\/\/mooredynasty.net\/?p=601"},"modified":"2012-12-15T18:25:08","modified_gmt":"2012-12-15T18:25:08","slug":"gitbitbucket-cheatsheet","status":"publish","type":"post","link":"https:\/\/mooredynasty.net\/index.php\/2012\/12\/gitbitbucket-cheatsheet\/","title":{"rendered":"Git\/BitBucket Cheatsheet"},"content":{"rendered":"<p>I use BitBucket for some low-key ASP.NET and Objective C source control needs. This is a cheatsheet of some of the things I do on an irregular basis.<\/p>\n<p><span style=\"text-decoration: underline;\">New ASP.NET Project Startup<\/span><\/p>\n<p>Usually about this time I&#8217;ll wonder if source control really is worth the hassle. Eventually I&#8217;ll decide (again) that it is.<\/p>\n<p>After creating the project in .NET and getting something coded that&#8217;s worth saving, I&#8217;ll <strong>initialize the solution folder for use with Git<\/strong>:<\/p>\n<blockquote><p>In Windows Explorer, right-click on the solution&#8217;s folder and do a <strong>Git Bash Here<\/strong> (I&#8217;m using Git for Windows)<\/p>\n<p>At the command prompt: \u00c2\u00a0<strong>git init<\/strong><\/p><\/blockquote>\n<p>This initialized the git repository but there&#8217;s nothing in there yet. \u00c2\u00a0Veterans of Visual Studio and other IDEs will know that there are numerous project-related files that don&#8217;t belong in your source control system. \u00c2\u00a0In Git, you can exclude them using a .gitignore file. \u00c2\u00a0By Googling, I arrived at an exclusion strategy that works for me, so I&#8217;ll usually just <strong>copy a .gitignore file from a previous project into the newly-initialized repository.<\/strong><\/p>\n<p>Now it&#8217;s time to<strong> add files to the repository<\/strong>. \u00c2\u00a0There&#8217;s probably an easier way, but I do it in 2 steps:<\/p>\n<blockquote><p><strong>git add *.sln<\/strong><\/p>\n<p><strong>git add ProjectFolder1<\/strong><\/p>\n<p><strong>git add ProjectFolder2<\/strong> (and so on&#8230;)<\/p><\/blockquote>\n<p>Now I can <strong>commit the files to the repository<\/strong>:<\/p>\n<blockquote><p><strong>git commit -a -m &#8220;Initial check-in or other clever comment&#8221;<\/strong><\/p><\/blockquote>\n<p>That&#8217;s good, but my real goal is to get a backup of the repository onto BitBucket. \u00c2\u00a0Creating a repository there is easily done via their web site. \u00c2\u00a0In fact, after this is done, BitBucket even gives you a mini-cheatsheet of how to push your local repository to the BitBucket remote.<\/p>\n<p>With the Bash window still open:<\/p>\n<blockquote><p><strong>$ cd \/path\/to\/my\/repo <\/strong><\/p>\n<p><strong>$ git remote add origin\u00c2\u00a0https:\/\/youraccount@bitbucket.org\/yourteam\/yournewrepository.git<\/strong><\/p>\n<p><strong>$ git push -u origin &#8211;all<\/strong><\/p><\/blockquote>\n<p>Note that the BitBucket SSH configuration must be performed on a new development machine for this to work.<\/p>\n<p>Also note that you&#8217;ll need your BitBucket account password to do the final push.<\/p>\n<p><span style=\"text-decoration: underline;\">Updates to an ASP.NET Project<\/span><\/p>\n<div>Updating a .NET project is pretty much the same as creating it.<\/div>\n<div><\/div>\n<div>New files are added with the <strong>git add<\/strong> command, then committed locally with <strong>git commit<\/strong>, as before.<\/div>\n<div><\/div>\n<div>Updates are then pushed to BitBucket using:<\/div>\n<blockquote><p><strong>$ git push origin master<\/strong><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I use BitBucket for some low-key ASP.NET and Objective C source control needs. This is a cheatsheet of some of the things I do on an irregular basis. New ASP.NET Project Startup Usually about this time I&#8217;ll wonder if source control really is worth the hassle. Eventually I&#8217;ll decide (again) &hellip; <\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-601","post","type-post","status-publish","format-standard","hentry","category-development"],"_links":{"self":[{"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/posts\/601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/comments?post=601"}],"version-history":[{"count":7,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/posts\/601\/revisions"}],"predecessor-version":[{"id":608,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/posts\/601\/revisions\/608"}],"wp:attachment":[{"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/media?parent=601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/categories?post=601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/tags?post=601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}