Some important nomenclature to understand:
Navigate to this site and sign in with your SUNet ID
Navigate to this site and click “download for Mac” and follow the instructions (which I will summarize below):
In the search bar type “terminal”.
Type “brew install git”
If it states you do not have the function brew then you must go here and follow the instructions (essentially copy and paste “/bin/bash -c”$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)” into terminal and then re-enter “brew install git” in terminal.
Navigate to this site: https://www.sourcetreeapp.com and click “Download for Mac OS X” and follow the instructions.
To link GitLab and Sourcetree you need to take the PAT (glpat-XzSkzLi3zwQpKxzsaX3V) obtained above and enter it when setting up a new account.
In Sourcetree, during setup click “connect” and “Add…” under the “Accounts” window click “Accounts”. For Stanford, under “Host” select “GitLab Enterprise” and enter the url https://code.stanford.edu, your username and your PAT as the password while under “Protocol” HTTPS is selected. For non-Stanford people the “Host” selection should be “GitLab.com” with remaining options same as in i. above.
Set GitLab as default and exit out of this screen.
In GitLab go to “Menu” in the top left corner and select “Projects” and then “Create New Project” and finally “Create blank project”.
Keep “Initialize repository with a README” under “Project Configuration” selected. This will then create all the initial files needed for a repository on GitLab and will then allow you to clone this repository to a local location of your choosing on your computer.
Open Sourcetree and select “Remote” on the top left-hand side, then highlight the GitLab repositories you would like to clone and click “Clone”.
Enter your name in the filter to quickly access your repository and select the arrow beside the repository you would like to locally clone.
Click location and select where you would like this repository to exist and click clone at the bottom right of the window and don’t forget to subsequently type the name of the new repository folder at the end of this path (it is a bit buggy and not intuitive). It is advisable you only place whatever you are ok with potentially being seen by others in this folder, keep data stored outside this folder.
You can then navigate yourself where ever you decided to place the repository above and make changes to your code/documents. Once you made a change it will be observable in Sourcetree.
Navigate to Sourcetree and click the repository you made changes to when you want to update it on GitLab.
Click the branch under “BRANCHES” option in the menu on the left-hand side where the change is located. You will see a list of changes, starting with the initial commit, in chronological order with the most recent at the top.
Select the “Uncommitted changes” option in the main panel and review the changes waiting to be committed in the bottom large panel.
Once you are ok with the changes made, click the “Commit” icon on the top left-hand side.
You then have the option of commenting on the commit at the bottom panel. It is recommended you do so to keep track of what is being done and why.
Here you can push changes to the origin/main branch if you select the box on the bottom-left prior to selecting Commit and immediately send the updated code/document to GitLab. You may not want to do this if there is a lot of changes to be made in a given repository and instead of spamming pushes to GitLab you can commit to many and push everything at once.
If you did not select push in the option prior to committing then you will notice a number icon on the “Push” icon on the top left. You now want to select this icon.
Work by Nicole Gladish
ngladish@stanford.edu