Git Usage and Download

This git work flow is designed for a single contributor. For more than one contributor, create a branch from master and attach it to a fork in personal github account.

Git is a distrubuted version control system that tracks the changes to files

  1. Download and install Git
  2. There are both command line and GUI interface tools. I typically use a built-in interface in PyCharm (a free python IDE), however this software is not required.
  3. To get started I use github to store my repositories. NIST has an official github account, but any folder can act as a git repository.
  4. Create a git repository with a read me file. From the GUI just choose create new repository and point at the desired directory. From the GIT command line utility (cd to the folder and run git init my_repository)
    • If this is to be a central repository run git init --bare my_repository.git instead)
    • If you do this at github github click create new repository making sure you select intialize with read me file.
  5. If you already know where the central repository is you can clone it to a directory on your local machine with git clone https://github.com/username/project command. This makes a copy of the directory on your computer.
  6. If you want to add files to the directory, you simply run: git add filename or for everything git add *
  7. This has added the file but to keep it, you need to commit it run: git commit -m "My comment here"
  8. Once you have commited the change to update the central repository you must push it. Run: git push
  9. To update your local copy you pull it. Run: git pull

My git workflow


  1. Every morning / time I open my code, I start with a git pull of the code:
    • git pull
  2. Anytime I get up from my desk I run 3 commands,
    • git add *
    • git commit
    • git push
  3. If there is software that has automatic saving I make sure to close it before I leave the machine. If you don't this creates a merge conflict, which is a pain to fix.
  4. If for some reason there is a conflict I can not fix, I delete the local copy and clone again. There are several circumstances in which you change the same line 2 places and you need to fix this. You can Merge the code, choosing the best one to keep.

Additional Notes

  1. There are a lot of tutorials, typically they cover much more information than you have to know to use git effectively, here is one that gives you the basics.
  2. In industry there is typically a meeting to make sure 2 people don't work on the same line of code at the same time.
  3. Git has bindings in a lot of languages, the python binding is gitpython