{"id":2965,"date":"2020-06-16T15:56:41","date_gmt":"2020-06-16T22:56:41","guid":{"rendered":"https:\/\/www.wellgolly.com\/?p=2965"},"modified":"2020-06-16T15:56:41","modified_gmt":"2020-06-16T22:56:41","slug":"git-commands-i-use","status":"publish","type":"post","link":"https:\/\/www.wellgolly.com\/?p=2965","title":{"rendered":"git Commands I Use"},"content":{"rendered":"<p>I started using git with my first Apple app because it was built into Xcode and one of the first lessons in the Stanford Xcode class recommended that we use it. I never used the branching features, since I\u2019m the only one working on the code, but I frequently made use of the lookback features so I could roll back code that didn\u2019t work or grab code that I had discarded but found out that I needed. So I basically used it for journaling.<\/p>\n<p>Most of the websites that I work on don\u2019t have lots of active users so when I want to make an update or something breaks, I just work on a copy or on the live files. However, I recently started a website that has active users and rather than only working in the site at night or making sure no one was using it before potentially breaking it, I decided to make a beta subdomain as I explained in some recent PHP-related posts. As long as I don\u2019t mess with the database I can break whatever I want and it doesn\u2019t affect users. <\/p>\n<p>At first I thought that I\u2019d use rsync to sync the two but git seems to work fine. The only problem is if I fix a small bug on the live site then I have trouble getting the new stuff to synchronize. I suppose I could figure out how to resolve differences, but an easier way is just to force the live site to match the beta site. Since they are on the same server, it doesn\u2019t take any time to synchronize.<\/p>\n<p><pre><code class=\"preserve-code-formatting\">\n git fetch --all\n git reset --hard origin\/master<\/code><\/pre><\/p>\n<p>The normal way to sync when I haven\u2019t made any changes is just:<br \/>\n<pre><code class=\"preserve-code-formatting\">\n git pull origin master<\/code><\/pre><\/p>\n<p>I also keep a copy as backup on my laptop with the same code.<br \/>\n<pre><code class=\"preserve-code-formatting\">\n&nbsp;&nbsp;\/\/ Do this once to establish the origin\n&nbsp;&nbsp;git remote add origin &quot;ssh:\/\/g@wellgolly.com\/www\/beta\/exercises\/.git&quot;\n&nbsp;&nbsp;\/\/ Do this when you want to synchronize\n&nbsp;&nbsp;git pull origin master<\/code><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I started using git with my first Apple app because it was built into Xcode and one of the first lessons in the Stanford Xcode class recommended that we use it. I never used the branching features, since I\u2019m the only one working on the code, but I frequently made use of the lookback features &hellip; <a href=\"https:\/\/www.wellgolly.com\/?p=2965\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">git Commands I Use<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-2965","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2965"}],"version-history":[{"count":6,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2965\/revisions"}],"predecessor-version":[{"id":2971,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2965\/revisions\/2971"}],"wp:attachment":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}