Difference between revisions of "Guide to Using Git"
From GlueXWiki
(→References) |
(→Add new files to git) |
||
Line 17: | Line 17: | ||
== Add new files to git == | == Add new files to git == | ||
− | * If you create new files or directories, they are initially "untracked;" you need to add them to git to track them. | + | * If you create new files or directories, they are initially "untracked;" you need to add them to git to track them. |
− | + | ||
− | === References === | + | ==== Example ==== |
+ | To add a file to git: | ||
+ | * <code>git add <myfile></code> | ||
+ | |||
+ | ==== References ==== | ||
* Guide: https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository | * Guide: https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository | ||
* Manual: http://git-scm.com/docs/git-add | * Manual: http://git-scm.com/docs/git-add |
Revision as of 16:35, 29 July 2015
Contents
Creating a local clone of the repository
- The first thing you need to do is to create a clone of the master repository on your local machine. The "git clone" command pulls all of the code, branches, etc. for the entire history of the project into the current, local directory.
- In general, you might want to have several separate branches of the repository built simultaneously on your machine. For example, you may want to have a program running off of "VersionA" and meanwhile develop code separately on "VersionB." To do this, you need multiple clones of the repository.
Examples
To create a clone of the master repository into the directory <mydir>:
- sim-recon:
-
cd $GLUEX_TOP/sim-recon/
-
git clone https://github.com/jeffersonlab/sim-recon/ <mydir>
-
- hdds:
-
cd $GLUEX_TOP/hdds/
-
git clone https://github.com/jeffersonlab/hdds/ <mydir>
-
References
- Guide: https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
- Manual: http://git-scm.com/docs/git-clone
Add new files to git
- If you create new files or directories, they are initially "untracked;" you need to add them to git to track them.
Example
To add a file to git:
-
git add <myfile>
References
- Guide: https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
- Manual: http://git-scm.com/docs/git-add
Create a local branch
-
cd sim-recon
-
git branch my_work
-
- Check-out the new branch
-
git checkout my_work
-