-
Wigal, Jacob (CIV) authoredWigal, Jacob (CIV) authored
This tutorial is for the following functions:
- create a local repository with files copied from a remote repository
- set a username and email to be associated with your future file edits
Before we begin
You will need to have “git” installed.
Follow the guide located here then read below.
Mac Users:
You may enter git commands in the “Terminal” application already on your computer.
Windows/PC Users:
You may enter git commands in “Anaconda Prompt”.
Get Started
Run the following commands in a command-line interface (e.g. Anaconda Prompt, Terminal) to download a remote repository and create a local repository to use in conjunction.
Step 1
Choose a location for your local repository. The end of the command in the cell below should be replaced with your desired filepath for your local repository. For your first time, just copy the filepath of your desktop.
Mac Users: this filepath will look something like…“/Users/username/Desktop”
Windows Users: this filepath will look something like…“C:\Users\username\Desktop"
cd /Users/username/Desktop
Step 2
Clone the remote repository to your new local repository. (syntax: git clone https//repositoryurlcom/repo.git) The repository URL of any repository can be found by going to our GitLab repository, selecting clone, and copying what shows up under "https". Once cloned, you will have the contents of that repository inside a new folder within your chosen file directory. Note: This new folder will be your git repository.

git clone https://gitlab.nps.edu/CID/get-started.git
You can now cd to your newly created git repository on your desktop. Note that in the future you will always need to cd to your git repository before using git commands.
cd /Users/username/Desktop/get-started
Step 3
Set a username and email to be associated with your future file edits. (Replace name and email within quotes. Note: You are not creating a log-in. You are only telling git your name and email so it can tell others who has made edits once you have started working.) You only have to do this once.
git config --global user.name "Firstname Lastname"
git config --global user.email "firstname.lastname@nps.edu"
Check Status
If the above was done correctly, you should see something similar to the following output: “On branch master, nothing to commit, working tree clean”
git status
That’s it!
Congratulations! If you have made it this far that means you have successfully installed git, and used git commands to get files. We will explore how to work with files and push them up to GitLab in the next guide.