Changes

Jump to navigation Jump to search
1,045 bytes added ,  18:05, 5 June 2023
no edit summary
Line 1: Line 1:  
<font size="3">GitHub is a web-based platform that provides hosting of coding repositories. It offers a centralized location for people to store, manage, and allow collaboration on their code. It is especially useful for version control and project tracking. The following information is geared towards linking gluey annex repositories with GitHub, but can easily be used to link your home computer to a GitHub repository. This wiki page is being updated as the author learns how to use GitHub, so if you know a better, more efficient way to accomplish a task then by all means please do it that way (... and add an addendum to this page if you have a login).</font>
 
<font size="3">GitHub is a web-based platform that provides hosting of coding repositories. It offers a centralized location for people to store, manage, and allow collaboration on their code. It is especially useful for version control and project tracking. The following information is geared towards linking gluey annex repositories with GitHub, but can easily be used to link your home computer to a GitHub repository. This wiki page is being updated as the author learns how to use GitHub, so if you know a better, more efficient way to accomplish a task then by all means please do it that way (... and add an addendum to this page if you have a login).</font>
   −
== <u><i>The Setup</i></u> ==
+
 
 +
== <i>Setup Option #1 (GitHub &#x2192; local computer)</i> ==
 +
Adding a repository in your GitHub account to your local computer (e.g. cloning).
 
<ol>
 
<ol>
 
<!-- Step 1 -->
 
<!-- Step 1 -->
Line 102: Line 104:  
</ol>
 
</ol>
   −
== <u><i>The Extras</i></u> ==
+
== <i>Setup Option #2 (Local computer &#x2192; GitHub)</i> ==
 +
Adding a repository from your local computer to GitHub
 +
<ol>
 +
<!-- Step 1 -->
 +
      <li>On your local computer, initialize the folder you want to adds as a repository:<br>
 +
      &ensp; - Use <b>cd</b> to navigate to the folder that contains the work you'd like to track/backup<br>
 +
      &ensp; - Type <b>git init</b> to initialize the folder for Git tracking<br>
 +
      &ensp; - (<i>optional step</i>) Type <b>touch .gitignore</b> to create a blank file in that folder, which can later be modify to specify files or types of files you don't want to track </li><br>
 +
 
 +
<!-- Step 2 -->
 +
      <li>Go to https://github.com/ , login, and create a repository as described above. Name the repository the same as your working folder you did the git init command in</li><br>
 +
 
 +
<!-- Step 3 -->
 +
      <li>On your local computer, link your working folder to the GitHub repsoitory:<br>
 +
      &ensp; - Type <b>git remote add origin <i>github-repository-url</i></b><br>
 +
      &ensp; &ensp; <i>github-repository-url</i> can be found online: <br>
 +
      &ensp; &ensp; &ensp; &ensp; - In your repository folder click on the green [<> Code] button then under the Local tab you'll see Clone HTTPS <br>
 +
      &ensp; &ensp; &ensp; &ensp; - Click the copy button to paste the address into the line of code above</li><br>
 +
 
 +
<!-- Step 4 -->
 +
      <li>On your local computer, merge the two repositories (local and online):<br>
 +
      &ensp; - Type <b>git pull origin main</b><br>
 +
      &ensp; &ensp; This assumes the GitHub branch is named <i>main</i> in the repository you created online </li><br>
 +
 
 +
<!-- Step 5 -->
 +
      <li>On your local computer, add files to track:<br>
 +
      <b>git add <i>folder-name</i></b><br>
 +
      &ensp; <i> - Adds the specified file or folder</i><br>
 +
      &emsp; OR <br>
 +
      <b>git add .</b> <br>
 +
      &ensp; <i> - Adds all new files and folders in the current directory recursively, does not add higher directory information</i><br>
 +
      &emsp; OR <br>
 +
      <b>git add -A</b> <br>
 +
      &ensp; <i> - Adds all files: new, modified, and deleted files. It will include files in the current directory and in higher directories that belong to the same git repository</i><br>
 +
      &emsp; OR <br>
 +
      <b>git add -u</b> <br>
 +
      <&ensp; <i> - Adds modified and deleted files only. Excludes new files. It will include files in the current directory and in higher directories that belong to the same git repository</i><br><br>
 +
      For a more detailed description of <i>git add</i> go to: https://github.com/git-guides/git-add</li><br>
 +
 
 +
<!-- Step 6 -->
 +
      <li>On your local computer, commit that add:<br>
 +
      &ensp; - Type <b>git commit -m "Message here"</b><br>
 +
      &ensp; &ensp; Change <i>Message here</i> to a brief description of the reason for the commit (ex: Initial commit) <br>
 +
      &ensp; &ensp; Make sure to keep "" </li><br>
 +
 
 +
<!-- Step 7 -->
 +
      <li>On your local computer, change (if required) the branch name to the name listed in the online repository:<br>
 +
      &ensp; - Typing <b>git branch</b> tells you the name(s) of the branch(es) with the current one having a * next to it<br>
 +
      &ensp; - If you need to modify your local computer's branch name use <b>git branch -M main</b> where <i>main</i> is the name to change the branch to<br>
 +
      &ensp; - Use <b>git branch</b> to verify the change </li><br>
 +
 
 +
<!-- Step 8 -->
 +
      <li>On your local computer, push your commit:<br>
 +
      &ensp; - Type <b>git push -u origin main</b><br>
 +
      &ensp; &ensp; You'll need to enter your GitHub profile name and your Personal Access Token to complete the push<br><br>
 +
      &ensp; - The purpose of the <i>-u</i> flag is to establish an upstream relationship between the local branch and the specified remote branch<br>
 +
      &nbsp; &nbsp; This is typically done on the initial push to a remote repository. After that, you don't need to use the -u flag again for subsequent pushes to the same branch </li><br>
 +
 
 +
<!-- Step 9 -->
 +
      <li>At this point your online GitHub repository should be the same as the working folder on your local computer <br>
 +
      &emsp; &nbsp; You can now continue to code and push/pull to GitHub as needed to track/update changes. Good luck, if it doesn't work don't blame me ... I only work here :) </li><br>
 +
</ol>
 +
 
 +
== <u><i>Extras</i></u> ==
 
<ul>
 
<ul>
 
<!-- 0 -->
 
<!-- 0 -->
Line 131: Line 196:     
<!-- 3 -->
 
<!-- 3 -->
  <li><u>Adding a repository from your local computer to GitHub</u><br>
+
      &ensp; 1) On your local computer, initialize the folder you want to adds as a repository:<br>
  −
      &ensp; &ensp; - Use <b>cd</b> to navigate to the folder that contains the work you'd like to track/backup<br>
  −
      &ensp; &ensp; - Type <b>git init</b> to initialize the folder for Git tracking<br>
  −
      &ensp; &ensp; - Type <b>touch .gitignore</b> to create a blank file in that folder, which can later be modify to specify files or types of files you don't want to track (<i>optional step</i>)<br><br>
  −
 
  −
      &ensp; 2) Go to https://github.com/ , login, and create a repository as described above. Name the repository the same as your working folder you did the git init command in<br><br>
  −
 
  −
      &ensp; 3) On your local computer link your working folder to the GitHub repsoitory:<br>
  −
      &ensp; &ensp; - Type <b>git remote add origin <i>github-repository-url</i></b><br>
  −
      &ensp; &ensp; &ensp; &ensp; <i>github-repository-url</i> can be found online. In your repository folder click on the green [<> Code] button then under the Local tab you'll see Clone HTTPS. Click the copy button to paste the
  −
                                    address into the line of code above<br><br>
  −
 
  −
      &ensp; 4) On your local computer, merge the two repositories (local and online):<br>
  −
      &ensp; &ensp; - Type <b>git pull origin main</b><br>
  −
      &ensp; &ensp; &ensp; &ensp; This assumes the GitHub branch is named <i>main</i> in the repository you created online<br><br>
  −
 
  −
 
  −
      &ensp; 5) On your local computer, add files to track:<br>
  −
      &ensp; &ensp; - Type <b>git add .</b><br><br>
  −
 
  −
      &ensp; 6) On your local computer, commit that add:<br>
  −
      &ensp; &ensp; - Type <b>git commit -m "Message here"</b><br>
  −
      &ensp; &ensp; &ensp; &ensp; Change <i>Message here</i> to a brief description of the reason for the commit (ex: Initial commit). Make sure to keep ""<br><br>
  −
 
  −
      &ensp; 7) On your local computer, change (if required) the branch name to the name listed in the online repository:<br>
  −
      &ensp; &ensp; - Typing <b>git branch</b> tells you the name(s) of the branch(es) with the current one having a * next to it<br>
  −
      &ensp; &ensp; - If you need to modify your local computer's branch name use <b>git branch -M main</b> where <i>main</i> is the name to change the branch to<br>
  −
      &ensp; &ensp; - Use <b>git branch</b> to verify the change<br><br>
  −
 
  −
      &ensp; 8) On your local computer, push your commit:<br>
  −
      &ensp; &ensp; - Type <b>git push -u origin main</b><br>
  −
      &ensp; &ensp; &ensp; &ensp; You'll need to enter your GitHub profile name and your Personal Access Token to complete the push<br><br>
  −
      &ensp; &ensp; - The purpose of the <i>-u</i> flag is to establish an upstream relationship between the local branch and the specified remote branch<br>
  −
      &emsp; &nbsp; &nbsp; This is typically done on the initial push to a remote repository. After that, you don't need to use the -u flag again for subsequent pushes to the same branch<br><br>
  −
 
  −
      &ensp; 9) At this point your online GitHub repository should be the same as the working folder on your local computer.<br>
  −
      &emsp; &nbsp; You can now continue to code and push/pull to GitHub as needed to track/update changes. Good luck, if it doesn't work don't blame me ... I only work here :) <br>
      
</li>
 
</li>
581

edits

Navigation menu