Difference between revisions of "Guide to Using Git"

From GlueXWiki
Jump to: navigation, search
(Adding files and/or Committing changes to git)
(Examples)
Line 27: Line 27:
 
</pre>
 
</pre>
 
To commit all of the staged files/folders in the current folder to git:
 
To commit all of the staged files/folders in the current folder to git:
* <code>git commit</code>
+
<pre>
 +
git commit
 +
</pre>
 
To commit all changes to "tracked" files/folders in the directory to git (bypassing the "add" staging: similar to "svn commit"):
 
To commit all changes to "tracked" files/folders in the directory to git (bypassing the "add" staging: similar to "svn commit"):
* <code>git commit -a </code>
+
<pre>
 +
git commit -a
 +
</pre>
  
 
=== References ===
 
=== References ===

Revision as of 21:36, 29 July 2015

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>:

References

Adding files and/or Committing changes to git

  • There are two cases where you might want to commit changes: New content and changes to existing content. In both cases, you must first "stage" the change with "git add," before committing it with "git commit."
    • Note that any changes made after "git add" but prior to "git commit" will NOT be committed; run "git add" again said changes in order to stage them for committing.
    • When you run "git commit" the text editor defined by the environment variable $EDITOR will be launched for you to add commit comments.

Examples

To stage a file/folder for the next commit (and/or add a new file):

git add <myfile>

To commit all of the staged files/folders in the current folder to git:

git commit

To commit all changes to "tracked" files/folders in the directory to git (bypassing the "add" staging: similar to "svn commit"):

git commit -a

References

Terminology

  • Tracked/untracked files: Untracked files are files that have never been added to git (via git add). Tracked files are ones that have been previously added to git.

Create a local branch

    • cd sim-recon
    • git branch my_work
  1. Check-out the new branch
    • git checkout my_work