{"id":5349,"date":"2019-06-08T11:02:18","date_gmt":"2019-06-08T16:02:18","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=5349"},"modified":"2019-06-17T11:08:23","modified_gmt":"2019-06-17T16:08:23","slug":"git-commands","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=5349","title":{"rendered":"Git Commands"},"content":{"rendered":"<p>There are a few git commands that we use when working with the OpenHAB and helper library repositories. The OpenHAB Eclipse project sets uses a split push\/pull repository where the *fetch* repo is the organization and the *push* repo is your personal repo. This is reasonable because you do not have permissions to write to the organizational repository. You can use the same split-repository setup for other projects. Clone the project either from the organization&#8217;s repo, and then change the push URL to your personal repository.<\/p>\n<p># Show list of remotes<br \/>\n[lisa@linux ~]# git remote -v<br \/>\norigin https:\/\/github.com\/openhab-scripters\/openhab-helper-libraries (fetch)<br \/>\norigin https:\/\/github.com\/openhab-scripters\/openhab-helper-libraries (push)<\/p>\n<p># Set push remote to PERSONAL repository<br \/>\n[lisa@linux ~]# git remote set-url &#8211;push origin https:\/\/github.com\/ljr55555\/openhab-helper-libraries<\/p>\n<p># Show list of remotes &#8212; verification step<br \/>\n[lisa@linux ~]# git remote -v<br \/>\norigin https:\/\/github.com\/openhab-scripters\/openhab-helper-libraries (fetch)<br \/>\norigin https:\/\/github.com\/ljr55555\/openhab-helper-libraries (push)<\/p>\n<p>While the split repository setup prevents accidentally attempting to push changes to a repo to which you lack write access, I find it a little confusing. Instead, I add specific repos for ORG (the organizational repo) and my personal repo.<br \/>\nThe drawback to this configuration is that you *can* attempt to push changes directly to the organization repo &#8212; which will either yield an error because you lack access or will inadvertently publish code in the org repo because you <em>don&#8217;t<\/em> lack access.<\/p>\n<p># Add ORG repo with organizational repo URL<br \/>\n[lisa@linux ~]# git remote add ORG https:\/\/github.com\/openhab-scripters\/openhab-helper-libraries<br \/>\n# Add LJR repo with personal fork URL<br \/>\n[lisa@linux ~]# git remote add LJR https:\/\/github.com\/ljr55555\/openhab-helper-libraries<br \/>\n[lisa@linux ~]# git remote -v<br \/>\nLJR https:\/\/github.com\/ljr55555\/openhab-helper-libraries (fetch)<br \/>\nLJR https:\/\/github.com\/ljr55555\/openhab-helper-libraries (push)<br \/>\nORG https:\/\/github.com\/openhab-scripters\/openhab-helper-libraries (fetch)<br \/>\nORG https:\/\/github.com\/openhab-scripters\/openhab-helper-libraries (push)<br \/>\norigin https:\/\/github.com\/openhab-scripters\/openhab-helper-libraries (fetch)<br \/>\norigin https:\/\/github.com\/ljr55555\/openhab-helper-libraries (push)<\/p>\n<p># Scenario: Someone has updated ORG master branch<br \/>\n# I want to incorporate those changes into PERSONAL master branch and push them into my repo<br \/>\n[lisa@linux ~]# git checkout master # Switch to your local master branch<br \/>\n[lisa@linux ~]# git fetch ORG\/master # Get changes from Organization master<br \/>\n[lisa@linux ~]# git rebase ORG\/master # Apply those changes to local master<br \/>\n[lisa@linux ~]# git push &#8211;force LJR master # Overwrite personal repo master with updated info<\/p>\n<p># Scenario: Someone has updated ORG master branch.<br \/>\n# I want to incorporate those changes in PERSONAL lucid-migration branch<br \/>\n[lisa@linux ~]# git checkout master # Switch to your local master branch<br \/>\n[lisa@linux ~]# git fetch ORG\/master # Get changes from Organization master<br \/>\n[lisa@linux ~]# git rebase ORG\/master # Apply those changes to local master<br \/>\n[lisa@linux ~]# git checkout lucid-migration # Switch back to your local lucid-migration branch<br \/>\n[lisa@linux ~]# git rebase &#8211;preserve-merges master # Rebase your local lucid-migration (checked out branch) onto local master<br \/>\n[lisa@linux ~]# git push &#8211;force-with-lease LJR lucid-migration # Overwrite personal repo lucid-migration branch with updated info<\/p>\n<p>&nbsp;<\/p>\n<p>And a few misc commands that I want to remember<br \/>\n# Check username and email<br \/>\n[lisa@linux ~]# git config &#8211;list<\/p>\n<p># Set username and e-mail address<br \/>\n[lisa@linux ~]# git config &#8211;global user.name &#8220;FIRST_NAME LAST_NAME&#8221;<br \/>\n[lisa@linux ~]# git config &#8211;global user.email &#8220;MY_NAME@example.com&#8221;<\/p>\n<p># merge gone bad, bail!<br \/>\n[lisa@linux ~]# git merge &#8211;abort<\/p>\n<p># Forgot to add sign-off on commit<br \/>\n[lisa@linux ~]# git commit &#8211;amend<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are a few git commands that we use when working with the OpenHAB and helper library repositories. The OpenHAB Eclipse project sets uses a split push\/pull repository where the *fetch* repo is the organization and the *push* repo is your personal repo. This is reasonable because you do not have permissions to write to &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[233],"class_list":["post-5349","post","type-post","status-publish","format-standard","hentry","category-coding","tag-git"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5349"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5349\/revisions"}],"predecessor-version":[{"id":5350,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5349\/revisions\/5350"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}