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://github.com/your-username/your-repository.git</b><br> <i>  - Make sure to replace "your-username" with your GitHub username and "your- | + | <li>Use the command:<br> |
− | repository"
| + | <b>git clone https://github.com/<i>your-username</i>/<i>your-repository</i>.git</b><br> |
− | with the name of your repository</i></li>
| + | <i>  - 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 <repository-url></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><repository-url></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>  - It will show all branches available and indicate your current branch with a * </i><br></li> | | <i>  - 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> |
− |   <i>- This will <b>create and switch</b> to the new branch in one step</i></li><br> | + |   <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> - Adds the specified file or folder</i><br> | | <i> - Adds the specified file or folder</i><br> |
|   OR <br> | |   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>  - Replace <b>Commit message</b> with a descriptive message summarizing the changes you made. Keep " " around your message</i></li><br> | + | <i>  - 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>  - 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>  - Replace branch-name with the name of the branch you want to push to (e.g., main)<br> |
| <i>  - You will need to login with your Username and Personal Access Token</li><br> | | <i>  - 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> |
− |   - The command shows the branch you're on, what files are in the working or staging directory, and other important information<br> | + |   - This command shows the branch you're on, what files are in the working or staging directory, and other important information<br> |
|   <u>Example</u>:<br> | |   <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> |
| + |   - 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> |
| + |   - This command undoes <i>git add</i> for uncommited changes to file <i>file-name</i><br></li><br> |
| + | |
| + | <!-- 3 --> |
| + | |
| | | |
| | | |