Skip to content

Utah2016 Git Information

schmelia edited this page May 7, 2016 · 5 revisions

Git

Installing Git

First check you have it: go to a terminal and type which git to see if you have it. Either you'll get nothing or you'll get a path. If you get nothing, you need to install it on your machine. Great directions for all three operating systems can be found at https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

Using Git

These steps only need to be done once.

  1. Make a folder (like M2Utah2016) for this workshop using mkdir
  2. Go to the main github page for the workshop and click on the code tab. Where it says HTTPS you will see an URL that starts with https://github.com/... (the ... is because it is much longer than this). Make a copy of that whole URL (Command V, ALt V etc).
  3. Change into the folder you made and type git clone and paste the url you copied and hit enter. So your command line will look something like git clone https://github.com/...(where, again, the ... indicates the rest of the correct url for this workshop).

These steps get repeated over and over.

Whenever you change a file (including adding a new file --- same steps) you should do these steps in this order.

git add Use this when you create a new file. Include the folder if you made a new folder for it too. This will help us keep things organized.

git commit Once you add you must commit (or git really has no idea you did anything). This command requires a comment. I find it easiest to comment by doing -m "Here is my comment", but you can also (if your terminal etc. are all set up ok for this) leave off the -m and it will open an editor for you to use and type in the comment. You can't avoid commenting and shouldn't.

git pull This will make sure that your local clone is up to date before you push. Also you need to always do a git pull before doing a git push (best is to do it right before).

git push This pushes the changes you have made to the repository in the cloud. This is done after you do a commit.

Some other things you may find helpful

If you need to remove any files from the repository use git rm. Then just like with using git add you need to commit and then pull and then push.