{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Git Usage and Download\n",
    "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. \n",
    "### Git is a distrubuted version control system that tracks the changes to files\n",
    "\n",
    "1. Download and install [Git] [git]\n",
    "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.\n",
    "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. \n",
    "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) \n",
    "    + If this is to be a central repository run git init --bare my_repository.git instead)\n",
    "    + If you do this at github [github] click create new repository making sure you select intialize with read me file. \n",
    "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. \n",
    "6. If you want to add files to the directory, you simply run: git add filename or for everything git add *\n",
    "7. This has added the file but to keep it, you need to commit it run: git commit -m \"My comment here\"\n",
    "8. Once you have commited the change to update the central repository you must __push__ it. Run: git push\n",
    "9. To update your local copy you __pull__ it. Run: git pull \n",
    "\n",
    "### My git workflow\n",
    "<hr/>\n",
    " 1. Every morning / time I open my code, I start with a git pull of the code: \n",
    "     + git pull\n",
    " 2. Anytime I get up from my desk I run 3 commands, \n",
    "     + git add *\n",
    "     + git commit\n",
    "     + git push\n",
    " 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.\n",
    " 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. \n",
    " \n",
    "\n",
    "### Additional Notes\n",
    "\n",
    "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][gittut].\n",
    "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. \n",
    "3. Git has bindings in a lot of languages, the python binding is [gitpython][gitpython]\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "[gitpython]:http://gitpython.readthedocs.org/en/stable/tutorial.html\n",
    "[gittut]:https://www.atlassian.com/git/tutorials/setting-up-a-repository/\n",
    "[github]:https://github.com/\n",
    "[git]:https://git-scm.com/downloads"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
