Emily Davenport Cut some text from box 2  about 9 years ago

Commit id: 9cd4a03d9cb589e7d30decdb08839ad8f20d50d5

deletions | additions      

       

\subsection{Box 2: Branching}  Do you ever make changes to your code, but are not sure you will want to keep those changes for your final analysis?Perhaps you want to incorporate new parameters into part of your pipeline, include a new covariate in your analyses, or add new functionality to a script. At the same time, you want to keep the original version of your scripts available in case you or your collaborators need to use them or if you decide not to include your changes.  Using git, you can maintain parallel versions of your code that you can easily bounce between while you are working on your changes. You can think of it like making a copy of the folder you keep your scripts in, so that you have your original scripts intact but also have the new folder where you make changes. Using git, this is called branching and it is better than separate folders because 1) it uses a fraction of the space on your computer, 2) keeps a record of when you made the parallel copy (branch) and what you have done on the branch, and 3) there is a way to incorporate those changes back into your main code if you decide to keep your changes (and a way to deal with conflicts). By default, your repository will start with one branch, usually called "master". To create a new branch in your repository, type \verb|git branch new_branch_name|. You can see what branches a current repository has by typing \verb|git branch|, with the branch you are currently in being marked by a star. To move between branches, type \verb|git branch checkout branch_to_move_to|. You can edit files and commit them on each branch separately. If you want combine the changes in your new branch with the master branch, you can merge the branches by typing \verb|git merge new_branch_name| while in the master branch.