On Github JonasAtWork / jonasatwork.github.io
Version Control Systems
Team Foundation Version Control
Git
Using Git
Using Git with GitHub
Git Workflows
Git Resources
Define a Project
Keep track of historical changes within a project
Make structural changes to the project
All of the work to keep track of files in a CVCS is ONLY done in one central place (i.e. the server)
Whether there are 1, 10, or 1000 developers working on a project, there is only ever one repository in a CVCS
this implies a few important points about a CVCS...
To work on the project files, you need access to the centralized server
we need network access to reach the server
There can only ever be one person editing a file at a time
All actions affecting the structure of the project...
All of the work to keep track of files in a DVCS is CAN be done anywhere the repository exists
A repository can exist on any machine (server, "team box", my machine, your machine ... anywhere)
this implies a few important points about a DVCS...
To work on the project files, you only need access to your local filesystem
You don't need network access to reach your repository
No one else can "lock" a file in your repository. This means...
...any file can be worked on within your own copy of the repository, regardless of who else may be working on that file
All actions affecting the structure of the project...
A file is read only when LOCKED, and writable when UNLOCKED
Changes to files are MERGED with the file that currently exists in the repository
Enterprise wide license for use of TFS
Deeply integrates with Visual Studios and Windows
TFVC handles big binary files very well
Not using a Microsoft stack (i.e. Java Developers)
Enterprise scale TFS may be overkill
TFVC is more susceptible to network problems
TFVC can be cumbersome with rapid development
Git is a tool developed for the command line
But Git has robust GUI's too
Deep integration with just about everything
Git can be as complex or simple as you need it to be
Works well remotely, without network access if needed
Flexible development workflows
Git encourages frequent branching and merging
Flexible development workflows do not imply different workflows
A "Distributed Repository" does not mean a "Backed Up Repository"
Git does not handle large numbers of big binary files very well
A copy of a repository is called a clone. Cloning a repository copies the entire repository from a remote location and recreates it on your machine
git clone git://github.com/jonasatwork/jonasatwork.github.io.git
Remember, the entire history is passed along every time you clone or synchronize a repository
Git does it's work by saving snapshots of repository objects.
view all the snapshots that Git has collected...
git log
Git is aware of all file additions, deletions, and modifications. You to decide what changes get grouped together into a commit
add changed files to the staging area to group them. Think of this as a future snapshot that you want Git to keep track of
git add index.html css/main.css
A commit creates a new snapshot consisting of the items in the staging area, and appends that snapshot to the end of the current branch
Pro Tip: Adding descriptive commit messages as you go is a great way to provide automated changelog documentation
git commit -m "adjusting element width and color on the main page"
A branch is one particular line in the tree of snapshots. We checkout a branch to make it active
When a branch is active all changes made to files are compared to the most recent snapshot in that branch
git checkout -b awesomeNewFeature
A merge tells Git to integrate all changes made in one branch to another branch
First, we need to move to the branch we want to merge changes into, then we the merge the branch containing all of our changes
git checkout master git merge awesomeNewFeature
Synchronizing your cloned repository with the remote repository, requires pulling in the most recent changes
git pull origin
pushing your changes back to the remote repository depends on your workflow and how the remote is setup
push your local changes to the remote repository you are allowed access to
git push origin master
Or submit your changes to the repository owner as a patch so that they may implement your changes (GitHub simplifies this step into a pull request, more on this later...)
Keeps track of all of your repositories
clone new repositories to your GitHub account. GitHub calls this forking
private repositories allows you to set which users can clone, pull, push, merge or even see the repository
Request for another developer to pull a branch from your repository into their repository
A Pull Request needs 4 pieces of information:
(GitHub handles much of this with a single button press)
Ultimately the owner of the destination repository decides whether or not to pull in your changes
A discussion thread for every pull request
-Linus Torvalds
(creator of Git)
Everyone works from one branch in central repository (usually called the master branch)
All changes in user's local repositories are pushed to the master branch
The master branch exists as the "production" version of code in the central repository
All changes in user's local repositories are initially pushed as separate branches to the central repository
These feature branches can be reviewed before merging them into the master branch
Git flow defines several branches representing different stages of your development process
All new development is done as a feature branch off of the Development branch