Upload
noam-kfir
View
378
Download
1
Tags:
Embed Size (px)
DESCRIPTION
I gave this presentation at the Israeli ALM User Group. This is part 1 of a 2 part series on Git and Git workflows and introduces the most basic Git functionality, especially as it differs from the Subversion and TFS version control systems.
Citation preview
Getting Started with Gita primer for svn and tfs users
Noam Kfir | Sela Group | 2014
Agenda
VCS Overview
Git in a Nutshell
Q&A
Version Control Systems (VCS)
• Backup code and other resources• Restore previous statesReversibility
• Share with the team• Make available to automated
processesConcurrency
• Comments, tags and other metadata• CommunicationAnnotation
Approaches to Version Control
CentralizedOne Authority
Connected
File System*
DistributedArbitrary Authority
Disconnected
Database
Basic Product Comparison
TFSWorkspace
Changesets
One stage:check in
SVNWorking Copy
Changesets
One stage:commit
GitFull Repository
Snapshots
Two stages:commit + push
Commits Are Local
Modify only the local repository index Do not modify the remote repository
Every commit: Creates a snapshot
Creates a new revision
Receives a new unique SHA-1 ref identifier
Supports completely disconnected workflows
More Advantages of Local Commits
Can accumulate multiple commits before integrating
Easier to group related commits
History can be cleaned up before pushing changes
More control over local environment
Snapshots over Deltas
Faster operations
Complex merges
Rewriting history
Advanced workflows
Installing Git on Windows
http://git-scm.com
Chocolatey: cinst git
TortoiseGit
GitExtensions
Visual Studio Team Explorer
And many more…
Configuration
Configuration Cascade local per repository
global per user
system per machine
Most common configurations are global
Some basic settings user.name
user.email
core.autocrlf
Excluding Files and Folders
Avoid storing user-specific and temporary files in the remote repository,by using the .gitignore file
The .gitignore file supports wildcards
Ignored files do not appear in the git status command output
Getting Started
git init repository-name Create a new repository
git remote add name url Link the local repository to a remote repository
git clone repository-url Copy and link an existing remote repository
Bare Repositories
No working folder
Contents nearly identical to non-bare .git folder
By convention, .git extension appended to bare repository name
Created with git init --bare or git clone repository --bare
Central repositories are almost always bare
Local repositories are almost never bare
Branches
A branch in Git points to a commit
It is not a container or a folder that stores files
git checkout [-b] branch Switch to the specified branch [after creating it]
git branch List and manage branches
Revision Selection and refs
Git uses special files to store information about its history
Every commit has a SHA-1 identifier – called the ref
You can refer to any commit, including remote commits, using the ref or a shorter ref
The revision selection syntax is very flexible. A few examples: HEAD~1
HEAD^^
master..branch
a1b2c3d
The Stage
Files ready to be committed are “on the stage”
Supports precise atomic commits – files and individual changes
git add files Stage files and/or changes to be committed
git status See an overview of the local changes
git commit -m message Create a commit with the staged changes
Some commands use the --cached parameter to refer to the stage
Working with Remote Repositories
git pull repository Fetch and merge git fetch repository Fetch the latest version from the remote
repository
git merge source-branch Merge the changes from the specified branch
git push repository Send the local commits to the remote repository
The Edit/Stage/Commit Sequence
git pull
(modify files)
git add file_or_folder
git status
git commit –m "Modified something or other”
git push
Merge Without Fear
Merging is central to git
Different types of merge strategies Usually selected automatically
Can be specified manually
pull = fetch + merge
Merge vs. Rebase
git merge
Copy
Adds to history
Usually safe
Good for traceability
Leaves messy history
git rebase
Move
Rewrites history
Can be dangerous
Good for cleanup
Makes history more linear
Rich Featureset
Stash Log Branches
refspec
Merge Algorithms Aliases grep Tags
Hooks .gitignore
cherry-pick reflog
reset revert Patches Remotes
Summary
Git is a very rich distributed version control system
Its distributed snapshot nature makes it extremely flexible and suitablefor many different types of work environments From individual programmers to small co-located teams to massive distributed teams
From open source projects to corporations
Git supported most of the workflows supported by TFS and SVN,but also offers additional benefits
Thank You!