{"id":3149,"date":"2017-06-06T12:18:07","date_gmt":"2017-06-06T12:18:07","guid":{"rendered":"http:\/\/wiki.davelevy.info\/?p=3149"},"modified":"2026-01-01T11:07:59","modified_gmt":"2026-01-01T11:07:59","slug":"using-git","status":"publish","type":"post","link":"https:\/\/davelevy.info\/wiki\/using-git\/","title":{"rendered":"Using GIT"},"content":{"rendered":"\n<p>I am fed up of having to look up how to make my git repos and upload them, so I am making this page. The <code>man<\/code> page <a href=\"https:\/\/www.kernel.org\/pub\/software\/scm\/git\/docs\/\">is here&#8230;<\/a>.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\">Making a new repo from a file system<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Make a repo on gh, with a <code>readme<\/code> file.<\/li>\n\n\n\n<li>run <code>git clone<\/code><\/li>\n\n\n\n<li>copy the files into the remote folder, <\/li>\n\n\n\n<li>and upload it to the repo, see <a href=\".\/examplecli\">the example code<\/a> on this page; gh have a size limit<\/li>\n<\/ol>\n\n\n\n<p>I needed to learn some new commands<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>git rm, <a href=\"https:\/\/stackoverflow.com\/questions\/41863484\/clear-git-local-cache\">see here<\/a><\/li>\n\n\n\n<li>git clean, <a href=\"https:\/\/git-scm.com\/docs\/git-clean\">see here<\/a><\/li>\n\n\n\n<li>git tag, <a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Git-Basics-Tagging\">see here<\/a>, which I have not yet done.<\/li>\n\n\n\n<li>I also found this, on <a href=\"https:\/\/github.com\/git-guides\/git-clone\">git clone<\/a>. <\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Loading Files into a Github Repo Branch<\/h3>\n\n\n\n<p>Using the command line on the local system, you will need a means of logging in, I used <code>gh auth login<\/code> which requires the installation of package <code>gh<\/code> and I used apt. The following step by step guide came from <a href=\"https:\/\/github.com\/git-guides\/git-add\">git-add<\/a> from github.com which has an example section dealing with the branches. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>git  clone &lt;repo name&gt;; this brings down the master<\/li>\n\n\n\n<li>git branch &lt;new branch names&gt; # this creates the branch and I believe that it is easier to do it on the command line, than to use the web site to create the branch.<\/li>\n\n\n\n<li>git branch -a, to check it&#8217;s worked<\/li>\n\n\n\n<li>git checkout &lt;same branch name as on line 2&gt;, this sets the default branch for push command<\/li>\n\n\n\n<li>git add . # adds the changes to commit buffer<\/li>\n\n\n\n<li>git commit -m &#8220;Describing update function&#8221;<\/li>\n\n\n\n<li>git push -u origin &lt;new branch name&gt;<\/li>\n\n\n\n<li>git push origin master<\/li>\n<\/ol>\n\n\n\n<p>Because I was unsure, I created a branch in the  web site, which I no longer need, so I deleted it. <\/p>\n\n\n\n<p>Further advice is available <a href=\"https:\/\/www.theserverside.com\/blog\/Coffee-Talk-Java-News-Stories-and-Opinions\/git-push-new-branch-remote-github-gitlab-upstream-example\">here<\/a>, but was for me less accessible and understandable. Critically it did not document in a way I wanted the checkout command. <\/p>\n\n\n\n<p>Next I need to reset my new branch as the master, <a href=\"https:\/\/blog.mergify.com\/everything-you-need-to-know-about-git-merge\/\">git merge performs an addition<\/a>, what I want to do is different, and I found <a title=\"Make the current Git branch a master branch\" href=\"https:\/\/stackoverflow.com\/questions\/2763006\/make-the-current-git-branch-a-master-branch\">this on substack<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Loading Files into a Github Repo before I used branches<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Use the web interface @ github.com to make an empty repo.<\/li>\n\n\n\n<li>On the development system, issue a <code>git clone<\/code> command, documented here &#8230;. You will need the repo file name from the web page.<\/li>\n\n\n\n<li>On the development system, copy the files to be included into the folder created by the git clone command and make that folder current. i.e. <code>cd $newly_created_folder<\/code>&nbsp;and then&nbsp; perform the following commands which are also explained in more detail here&#8230;..<\/li>\n<\/ol>\n\n\n\n<p class=\"has-text-align-center\">ooOOOoo<\/p>\n\n\n\n<a name=\"examplecli\"><\/a>\n\n\n\n<pre class=\"wp-block-preformatted\">$&nbsp;&nbsp; &nbsp; git add .                                    \n$&nbsp;&nbsp; &nbsp; git config --global user.email \"john.doe@spammenot.co.uk\"\n$&nbsp;&nbsp; &nbsp; git config --global user.name \"John Doe\"\n$&nbsp;&nbsp; &nbsp; git commit -m \"Initial Version\"\n$&nbsp;&nbsp; &nbsp; git remote -v || git remote add origin ${REPO_URL} \n$&nbsp;&nbsp; &nbsp; git push origin master\n<\/pre>\n\n\n\n<p>&#8212;<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>$ git add .<\/code>&nbsp; copies the files to the local copy of the repo<\/li>\n\n\n\n<li><code>$ git config --global user.email \"john.doe@spammenot.co.uk\"<\/code>&nbsp; which partly establishes identity of author<\/li>\n\n\n\n<li><code>$ git config --global user.name \"Dave Levy\"<\/code>&nbsp; which partly establishes identity of author<\/li>\n\n\n\n<li><code>$ git commit -m \"Initial Version\"<\/code> commits the changes to the local repo<\/li>\n\n\n\n<li><code>$ git remote -v || git remote add origin ${REPO_URL}<\/code>&nbsp; tests if the remote repo is set and sets it if not<\/li>\n\n\n\n<li><code>$ git push origin master<\/code>&nbsp; moves the files to the remote repo, will require login credentials.<\/li>\n<\/ol>\n\n\n\n<p>In various places, it advises not to commit until you&#8217;ve finished. Also the man page deals with environment variables.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">On Branches &amp; Versions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/itnext.io\/the-github-development-workflow-fb48d9bb63f9\">https:\/\/itnext.io\/the-github-development-workflow-fb48d9bb63f9<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/gist.github.com\/nzakas\/7633640\">https:\/\/gist.github.com\/nzakas\/7633640<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/nvie.com\/posts\/a-successful-git-branching-model\/\">https:\/\/nvie.com\/posts\/a-successful-git-branching-model\/<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Git-Branching-Branches-in-a-Nutshell\">https:\/\/git-scm.com\/book\/en\/v2\/Git-Branching-Branches-in-a-Nutshell<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>I am fed up of having to look up how to make my git repos and upload them, so I am making this page. The man page is here&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":2612,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_share_on_mastodon":"0"},"categories":[27,3],"tags":[864,865,54,920,911],"class_list":["post-3149","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","category-technology","tag-git","tag-github","tag-howto","tag-software","tag-technology"],"share_on_mastodon":{"url":"https:\/\/mastodon.social\/@davelevy_eu\/111976366436065110","error":""},"jetpack_featured_media_url":"https:\/\/davelevy.info\/wiki\/wp-content\/uploads\/2015\/04\/github_icon-w200.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/3149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/comments?post=3149"}],"version-history":[{"count":9,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/3149\/revisions"}],"predecessor-version":[{"id":13715,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/3149\/revisions\/13715"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/media\/2612"}],"wp:attachment":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/media?parent=3149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/categories?post=3149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/tags?post=3149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}