Skip to content
Kenny Yu edited this page Oct 23, 2013 · 1 revision

Huh?

So what exactly did you do when you clicked the Fork button and then executed the clone command? To explain this, let's first dive into the git's data model and define a few important terms.

Data model

Here's a few important terms:

  • repository - the entire contents of a project. In our case, that is the bootcamp-git folder living on your computer, or your bootcamp-git repository on github.

  • commit - a snapshot of the entire project at a specific point in time. A commit is usually identified by a random string (called a hash, e.g. 0fb4cde). Each commit encapsulates a set of changes to a set of files (these changes are collectively called a diff). Git gives us a nice way to see exactly what changes we make to files, and commits allow us to revert back to a previous snapshot in history.

  • remote - another repository that your project knows about. As an example, if you cd bootcamp-git on your local copy, and then type git remote -v, that will list all the remote repositories that your local repository knows about. If you followed our directions, you should have something called origin that points to your repository on github. remote

  • branch - a chain of commits associated together into one logical line of development. By default, all repositories start with a branch called master. If you are currently on master and you make a commit, you've advanced master forward by one commit. Engineers typically use a branch to keep all the changes for a new feature together, and then when they're ready, merge back into the mainline. As an example, our bootcamp-git repository looks like this: branches In this example, origin/master, master, merge-exercise, and origin/merge-exercise are all branches in our repository. master and merge-exercise diverged from commit 4b40046 - Adding aliases.

Git Environments

When you work with git, there are 4 key environments that you should be aware of.

  1. local file system - files on your local machine and all their modifications. Changes only in your local file system are not yet snapshotted by git.
  2. staging area - changes that will be snapshotted the next time you run git commit. To add the changes in a file to the staging area, use git add.
  3. local repository - local history of all the changes to a project. To create a snapshot, use git commit, which will take everything from the staging area, and create a commit into your local repository.
  4. remote repository - history of all the changes to a project, possibly living on an entirely different machine (e.g. github). To sync your local and remote repositories, use git push and git pull.

Here's a diagram that summarizes the environments and the commands to move objects between the environments: environments

Finish Bootcamp

Go back to the main page.