Changes

Jump to navigation Jump to search
390 bytes added ,  15:50, 31 May 2023
no edit summary
Line 42: Line 42:  
           <li>You can do the same for your home computer, you'll just need to open a terminal or command prompt and navigate to the directory where you want to store your code</li>
 
           <li>You can do the same for your home computer, you'll just need to open a terminal or command prompt and navigate to the directory where you want to store your code</li>
 
         </ul>
 
         </ul>
       <li><u>Type the command:</u><br> <b>git clone https&#58;&#47;&#47;github&#46;com&#47;your-username&#47;your-repository&#46;git</b><br> <i>&ensp; - Make sure to replace "your-username" with your GitHub username and "your-  
+
       <li>Use the command:<br>
            repository"  
+
          <b>git clone https&#58;&#47;&#47;github&#46;com&#47;<i>your-username</i>&#47;<i>your-repository</i>&#46;git</b><br>  
            with the name of your repository</i></li>
+
          <i>&ensp; - Make sure to replace "your-username" with your GitHub username and "your-repository" with the name of your repository</i></li>
       <li>You will now need to login. Use your <b>GitHub Username</b>, but make sure to use the <b>Personal Access Token</b> you created earlier and <b><u>NOT</u></b> your GitHub password</li>
+
       <li>You will now need to login. Use your <u>GitHub Username</u>, but make sure to use the <u>Personal Access Token</u> you created earlier and <b><u>NOT</u></b> your GitHub password</li>
 
     </ul><br>
 
     </ul><br>
   Line 51: Line 51:  
   <li>At this point you should have a new folder in your annex with the name of your GitHub repository</li>
 
   <li>At this point you should have a new folder in your annex with the name of your GitHub repository</li>
 
     <ul>
 
     <ul>
       <li>Confirm that the remote repository is correctly added, use the command:<br> <b>git remote -v</b><br></li>
+
       <li>Confirm that the remote repository is correctly added, use the command:<br>  
       <li>If needed, you can link the local repository to the remote repository using:<br> <b>git remote add origin &lt;repository-url&gt;</b><br></li>
+
          <b>git remote -v</b><br></li>
 +
       <li>If needed, you can link the local repository to the remote repository using:<br>  
 +
          <b>git remote add origin <i>&lt;repository-url&gt;</i></b><br></li>
 
     </ul><br>
 
     </ul><br>
   Line 58: Line 60:  
   <li>To switch to or determine a branch in Git, you can use the git checkout command:
 
   <li>To switch to or determine a branch in Git, you can use the git checkout command:
 
     <ul>
 
     <ul>
       <li>Determine the name of the branch you want to switch to via:<br> <b>git branch</b><br>  
+
       <li>Determine the name of the branch you want to switch to via:<br>  
 +
          <b>git branch</b><br>  
 
           <i>&ensp; - It will show all branches available and indicate your current branch with a * </i><br></li>
 
           <i>&ensp; - It will show all branches available and indicate your current branch with a * </i><br></li>
 
       <li>Create a new branch using: <br>  
 
       <li>Create a new branch using: <br>  
           <b>git branch new-branch-name</b> </li>
+
           <b>git branch <i>new-branch-name</i></b> </li>
 
       <li>Switch to that branch and work in it via:<br>
 
       <li>Switch to that branch and work in it via:<br>
           <b>git checkout new-branch-name</b> <br></li><br>
+
           <b>git checkout <i>new-branch-name</i></b> <br></li><br>
 
       <li>The two steps above can be combined:<br>  
 
       <li>The two steps above can be combined:<br>  
           <b>git checkout -b new-branch-name</b> <br>
+
           <b>git checkout -b <i>new-branch-name</i></b> <br>
           &ensp; <i>- This will <b>create and switch</b> to the new branch in one step</i></li><br>
+
           &ensp; <i>- This will <u>create and switch</u> to the new branch in one step</i></li><br>
 
     </ul>
 
     </ul>
   Line 75: Line 78:  
   <li>When you're ready to save, make sure you are in the root directory of your repository or the directory where the new folder you want to save is located. Then use the git add command to add the new folder and its contents to  
 
   <li>When you're ready to save, make sure you are in the root directory of your repository or the directory where the new folder you want to save is located. Then use the git add command to add the new folder and its contents to  
 
       the staging area. Run the following command:<br>
 
       the staging area. Run the following command:<br>
   <b>git add folder-name</b><br>
+
   <b>git add <i>folder-name</i></b><br>
 
       <i>&ensp;- Adds the specified file or folder</i><br>
 
       <i>&ensp;- Adds the specified file or folder</i><br>
 
   &emsp; OR <br>
 
   &emsp; OR <br>
Line 89: Line 92:     
<!-- Step 9 -->
 
<!-- Step 9 -->
   <li>Once the new folder/file is added to the staging area, you can commit the changes using the git commit command:<br> <b>git commit -m "Commit message"</b> <br>
+
   <li>Once the new folder/file is added to the staging area, you can commit the changes using the git commit command:<br> <b>git commit -m "<i>Commit message</i>"</b> <br>
       <i>&ensp; - Replace <b>Commit message</b> with a descriptive message summarizing the changes you made. Keep " " around your message</i></li><br>
+
       <i>&ensp; - Replace Commit message with a descriptive message summarizing the changes you made. Keep " " around your message</i></li><br>
    
<!-- Step 10 -->
 
<!-- Step 10 -->
   <li>After committing the changes (on your local machine), you can push them to the remote repository on GitHub using the git push command:<br> <b>git push origin branch-name</b><br>
+
   <li>After committing the changes (on your local machine), you can push them to the remote repository on GitHub using the git push command:<br>  
       <i>&ensp; - Replace <b>branch-name</b> with the name of the branch you want to push to (e.g., main)<br>
+
      <b>git push origin <i>branch-name</i></b><br>
 +
       <i>&ensp; - Replace branch-name with the name of the branch you want to push to (e.g., main)<br>
 
       <i>&ensp; - You will need to login with your Username and Personal Access Token</li><br>
 
       <i>&ensp; - You will need to login with your Username and Personal Access Token</li><br>
 
</ol>
 
</ol>
Line 102: Line 106:  
<!-- 1 -->
 
<!-- 1 -->
 
   <li><b>git status</b><br>
 
   <li><b>git status</b><br>
       &ensp; - The command shows the branch you're on, what files are in the working or staging directory, and other important information<br>
+
       &ensp; - This command shows the branch you're on, what files are in the working or staging directory, and other important information<br>
 
       &emsp; <u>Example</u>:<br>
 
       &emsp; <u>Example</u>:<br>
 
       <pre>        mcintyre@gluey/nfs/direct/annex/mcintyre/GitRepo/Radphi_pi02gp/RUN0
 
       <pre>        mcintyre@gluey/nfs/direct/annex/mcintyre/GitRepo/Radphi_pi02gp/RUN0
Line 117: Line 121:     
<!-- 2 -->
 
<!-- 2 -->
 +
  <li><b>git reset</b><br>
 +
      &ensp; - This command unstages all changes (e.g. all <i>git add</i> performed before a <i>git commit</i>)<br></li>
 +
  <li><b>git reset <i>file-name</i></b><br>
 +
      &ensp; - This command undoes <i>git add</i> for uncommited changes to file <i>file-name</i><br></li><br>
 +
 +
<!-- 3 -->
 +
     
581

edits

Navigation menu