NCARB	CHECKOUT	GIT
TOPICS	IN	THIS	TALK
Introduction
Design	Goals
Architecture
Using	Git
-	Basics
-	Branching
-	Collaboration
Git	with	Visual	...
GIT	CULTURE
Everything	is	a	Feature	Branch
Commit	often	as	work	progresses
Developers	don't	ask	for	permission:	
Clone	and...
HISTORY
Developed	in	April	2005	by	Linus	Torvalds
PRE	GIT
Linux	Collaborators	worked	with	patches
then	Bitkeeper	and	fallo...
DESIGN	GOALS
Distributed
Reliable
Quick
ACHIEVED	THROUGH	ARCHITECTURE	AND	GOOD	CODE
DISTRIBUTED
The	entire	repository	is	copied.
Repository	work	is	done	offline
because	you	have	the	whole	repository	with	yo...
RELIABLE
Each	object's	filename	is	its	hash:
easy	to	verify.
DISTRIBUTED	==	RELIABLE
If	your	repository	is	lost,
just	ask	...
GIT	FEATURE:	QUICK
Snapshots,	not	diffs.
Fast	operations	on	switching,	merging,	and	committing.
Simple	architecture	with	k...
ARCHITECTURE
EACH	OBJECT'S	FILENAME	IS	ITS	HASH
OBJECTS
Files,	Directories,	Commits
POINTERS
Branches,	HEAD,	Tags
OBJECTS
Hello.txt
e965047ad7c57865823c7d992b1d046ea66edf78
Hellon
Directory	Containing	Hello.txt
2ea873e13e84497d7459150a0...
POINTERS
Master	Branch
.git/refs/heads/master
849d9a4ec0e853151ca4e8ff630feee25d701386
HEAD
.git/HEAD
ref:	refs/heads/mast...
USING	GIT
Basics
Branching
Collaboration
BASICS
Setup	a	Repository
Stage	Files
Commit	Staged	Files
Undo	Changes
Tagging
SETUP	A	REPOSITORY
CREATE	A	REPOSITORY
	git	init
Creates	a	repository	filesystem	in	the	.git	subdirectory	
SET	NAME	AND	EM...
Stages	files;	files	are	now	tracked.	
STAGE	FILES
	git	add	.
Further	modifications	to	the
same	file	remain	unstaged	until	...
Amend	is	an	easy	way	to	add	to	what	was	just	committed
COMMIT	FILES
	git	commit	-m	"Commit	message"
Branch	now	points	to	n...
UNDOING	THINGS
	git	checkout	--	filename1	filename2
	git	clean	-f
Revert	unstaged	changed	to	their	staged	or	committed	sta...
TAGGING
	git	tag	-a	2.0	-m	"Mid	August	Release"
Adds	a	tag	on	branch's	last	commit
	git	describe
	2.0-12-8bd3fe1
Current	c...
BRANCHES
Ethos
Creating
Merging
Resolving	Conflicts
Rebasing
Squashing
BRANCH	ETHOS
Branching,	Checking	out,	and	Merging
	is	cheap	and	fast
It	keeps	the	master	branch	golden
We	branch	within	ou...
Switches	your	working	files	to	this	branches	files
Shortcut:	creates	the	branch	and	checks	it	out
BRANCH	CREATION
	git	bra...
Lists	branches;	stars	current	branch
Deletes	a	branch
BRANCH	MANAGEMENT
	git	branch
	*	master
			feature1
	git	branch	-D	f...
MERGING
	git	checkout	master
	git	merge	abranch
Merges	changes	in	abranch	into	master
FAST-FORWARD	MERGE
When	commits	have...
MERGING
COMPOSITE	MERGE
When	both	branches	have	changed
and	can	be	cleanly	merged,
a	new	commit	object	is	created;
it	has	...
CONFLICTS
	git	merge	abranch
	Auto-merging	hello.txt
	CONFLICT	(content):	Merge	conflict	in	hello.txt
	Automatic	merge	fai...
REBASING
Reconfigure	branch	history	so	that	the	same	changes	are
based	on	a	different	commit
Reconfigures	abranch	so	that	...
Brings	up	an	edit-list	of	commits	to	squash	together
SQUASHING
When	you	are	already	are	without	conflicts...
	git	rebase	m...
COLLABORATING
Cloning
Pull
Push
CLONE
	git	clone	https://github.com/ncarb/Repo.git
Init	+	Copies	repository	+	adds	remote	references
	git	remote	add	me	ht...
Shortcut	for	doing	a	fetch	and
Set	a	branch	to	track	origin's
PULL
	git	pull
Shortcut	for	doing	a	fetch	and
merging	change...
Pushes	local	commits	to	the	remote.
Pushes	a	tag	to	a	remote	repository
PUSH
	git	push	[remote]
If	there	have	been	changes...
VISUAL	STUDIO	INTEGRATION
msys-git
posh-git
GitHub	for	Windows
See	Git
Visual	Studio	Git	Provider
git-tfs
MSYS-GIT
Basic	Command-line	support
Git	Bash	Shell
Git	GUI
POSH	GIT
Powershell	Enhanced	Git	Command-line	Experience
	C:UsersdandersonDev	[master	+3	~4	-0	|	+0	~1	-0]>
Fancy,	color-c...
GITHUB	FOR	WINDOWS
Simple	GitHub	account	management
App	eye-candy
Fun	to	view	history
Fun	to	view	unified	diffs
Easy	to	sy...
SEE	GIT
Visual	Application	for	Git
VISUAL	STUDIO	GIT	PROVIDER
Team	Explorer:
Changed	Files,	Commit,	Push,	Pull,	
Conflict	Resolution
Solution	Explorer:
File	...
GIT-TFS
Plugin	for	Git	command-line
	git	tfs	clone	http://tfs:8080/tfs/DefaultCollection	$/Project
	git	checkout	-b	story
...
GITHUB
Popular
Thriving	Community
Great	Code	Web	Experience
Organization	Support
Pull	Requests
Sophisticated	Code	Review
R...
GITHUB	INTEGRATION
DEVELOPER	EXPERIENCE
track	main	repository
pull	request	when	ready	for	review
request	is	verfied	by	Tea...
GITHUB	INTEGRATION
REVIEWER	EXPERIENCE
Pull	Requests	are	checked	by	Team	City;
notifications	in	pull	request	comments
Easi...
CONCLUSION
Git	is	a	well-designed	version	control	system.
Microsoft	supports	Git.
We	are	using	git	locally	with	git-tfs	ri...
Upcoming SlideShare
Loading in...5
×

NCARB Checkout Git

180

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
180
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

NCARB Checkout Git

  1. 1. NCARB CHECKOUT GIT
  2. 2. TOPICS IN THIS TALK Introduction Design Goals Architecture Using Git - Basics - Branching - Collaboration Git with Visual Studio GitHub
  3. 3. GIT CULTURE Everything is a Feature Branch Commit often as work progresses Developers don't ask for permission: Clone and send a pull request Maintainers pick and choose what to merge Delegated network of trust
  4. 4. HISTORY Developed in April 2005 by Linus Torvalds PRE GIT Linux Collaborators worked with patches then Bitkeeper and fallout NOW Maintained by Junio Hamano
  5. 5. DESIGN GOALS Distributed Reliable Quick ACHIEVED THROUGH ARCHITECTURE AND GOOD CODE
  6. 6. DISTRIBUTED The entire repository is copied. Repository work is done offline because you have the whole repository with you.
  7. 7. RELIABLE Each object's filename is its hash: easy to verify. DISTRIBUTED == RELIABLE If your repository is lost, just ask for another developer's copy.
  8. 8. GIT FEATURE: QUICK Snapshots, not diffs. Fast operations on switching, merging, and committing. Simple architecture with kernel hacker refinements. DISTRIBUTED == QUICK All operations are local.
  9. 9. ARCHITECTURE EACH OBJECT'S FILENAME IS ITS HASH OBJECTS Files, Directories, Commits POINTERS Branches, HEAD, Tags
  10. 10. OBJECTS Hello.txt e965047ad7c57865823c7d992b1d046ea66edf78 Hellon Directory Containing Hello.txt 2ea873e13e84497d7459150a0b2b662403e3bc2b 100644 blob e965047ad7c57865823c7d992b1d046ea66edf78 Hello.txt Commit of Directory Containing Hello.txt 849d9a4ec0e853151ca4e8ff630feee25d701386 tree 2ea873e13e84497d7459150a0b2b662403e3bc2b parent 2dce1bf1497951717f34a3a0d9605436e0477832 author DAnderson <danderson@ncarb.org> 1375967945 -0400 committer DAnderson <danderson@ncarb.org> 1375968283 -0400 Committed Hello.txt
  11. 11. POINTERS Master Branch .git/refs/heads/master 849d9a4ec0e853151ca4e8ff630feee25d701386 HEAD .git/HEAD ref: refs/heads/master config .git/config (snippet) [remote "origin"] url = https://github.com/davious/PrepGit.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master
  12. 12. USING GIT Basics Branching Collaboration
  13. 13. BASICS Setup a Repository Stage Files Commit Staged Files Undo Changes Tagging
  14. 14. SETUP A REPOSITORY CREATE A REPOSITORY git init Creates a repository filesystem in the .git subdirectory SET NAME AND EMAIL git config user.name "DAnderson" git config user.email "danderson@ncarb.org" Used in all commit files
  15. 15. Stages files; files are now tracked. STAGE FILES git add . Further modifications to the same file remain unstaged until the next add. Shows which files are tracked, which files are modified Shows line-by-line changes between modified and staged/committed Shows line-by-line changes between staged and committed git status git diff git diff --cached
  16. 16. Amend is an easy way to add to what was just committed COMMIT FILES git commit -m "Commit message" Branch now points to new commit file. Commit files point to previous parent(s). git commit -m "Commit message" --amend or just redo the commit message git log Review past commits
  17. 17. UNDOING THINGS git checkout -- filename1 filename2 git clean -f Revert unstaged changed to their staged or committed state; clean deleted untracked files git reset HEAD git reset HEAD filename1 filename2 Unstage staged files git reset --hard Throw away all work git reset --hard HEAD^2 Undo last two commits
  18. 18. TAGGING git tag -a 2.0 -m "Mid August Release" Adds a tag on branch's last commit git describe 2.0-12-8bd3fe1 Current commit description based on last created tag {last tag name}-{revisions since}-{short hash of commit}
  19. 19. BRANCHES Ethos Creating Merging Resolving Conflicts Rebasing Squashing
  20. 20. BRANCH ETHOS Branching, Checking out, and Merging is cheap and fast It keeps the master branch golden We branch within our own repositories; so, the main repository remains uncluttered SO, FOR EACH ENDEAVOR, BRANCH
  21. 21. Switches your working files to this branches files Shortcut: creates the branch and checks it out BRANCH CREATION git branch newbranch # master, newbranch >> A; HEAD >> master Creates a new branch git checkout newbranch # HEAD >> abranch Note: Any staged files remained staged git checkout -b newbranch # master, newbranch >> A; HEAD >> abranch newbranch is now your current working branch
  22. 22. Lists branches; stars current branch Deletes a branch BRANCH MANAGEMENT git branch * master feature1 git branch -D feature1
  23. 23. MERGING git checkout master git merge abranch Merges changes in abranch into master FAST-FORWARD MERGE When commits have only been added to a branch, just point to the branch's commit object master >> A master, newbranch >> A master >> A <- B << newbranch A <- B << master, newbranch
  24. 24. MERGING COMPOSITE MERGE When both branches have changed and can be cleanly merged, a new commit object is created; it has two parents. B (master work) ↙ ↖ A D (merge) ↖ ↙ C (newbranch work)
  25. 25. CONFLICTS git merge abranch Auto-merging hello.txt CONFLICT (content): Merge conflict in hello.txt Automatic merge failed; fix conflicts and then commit the result. git mergetool git commit The result is just like a composite merge. Typical Conflict Markup <<<<<<< HEAD Line modified in master ======= Line modified in abranch >>>>>>> abranch git merge abranch /conflict: you can hand edit it/ git add . git commit
  26. 26. REBASING Reconfigure branch history so that the same changes are based on a different commit Reconfigures abranch so that when master merges it, it is a fast-forward merge B ↙ A ⇒ A ← B ← C ↖ C git checkout abranch git rebase master
  27. 27. Brings up an edit-list of commits to squash together SQUASHING When you are already are without conflicts... git rebase master -i --autofix Undoes all commits, but keeps changes staged for a commit Commit to master branch in one commit git reset --soft master git commit -m "abranches work, now in one commit" git checkout master git merge --squash abranch git commit -m "abranch in one commit"
  28. 28. COLLABORATING Cloning Pull Push
  29. 29. CLONE git clone https://github.com/ncarb/Repo.git Init + Copies repository + adds remote references git remote add me https://github.com/davious/Repo.git Adds a remote git fetch Brings down objects from remote repository updates remote branch stored locally
  30. 30. Shortcut for doing a fetch and Set a branch to track origin's PULL git pull Shortcut for doing a fetch and merging changes into the branch git pull --rebase rebasing the branch to be a fast-forward of the remote git branch -u origin/master master branch Set a new branch to track origin's master branch git checkout -b abranch origin/master
  31. 31. Pushes local commits to the remote. Pushes a tag to a remote repository PUSH git push [remote] If there have been changes since your last fetch, your push will be cancelled. git remote set-url --push origin https://github.com/davious/Repo.git Changes the default repository you push to git push -f Force the remote to accept out-of-sync changes. Not usually done while collaborating. git push origin 2.0
  32. 32. VISUAL STUDIO INTEGRATION msys-git posh-git GitHub for Windows See Git Visual Studio Git Provider git-tfs
  33. 33. MSYS-GIT Basic Command-line support Git Bash Shell Git GUI
  34. 34. POSH GIT Powershell Enhanced Git Command-line Experience C:UsersdandersonDev [master +3 ~4 -0 | +0 ~1 -0]> Fancy, color-coded command prompt Auto-completed git commands and arguments branch upstream: in sync , ahead, behind, both files: staged , unstaged + = added files ~ = modified files - = deleted files
  35. 35. GITHUB FOR WINDOWS Simple GitHub account management App eye-candy Fun to view history Fun to view unified diffs Easy to sync local repositories with GitHub repositories Msys-Git and Posh-Git are bundled in with it
  36. 36. SEE GIT Visual Application for Git
  37. 37. VISUAL STUDIO GIT PROVIDER Team Explorer: Changed Files, Commit, Push, Pull, Conflict Resolution Solution Explorer: File Status, History Improvements forthcoming Integrated with Team Foundation Service Note: Solution Provider is git add agnostic
  38. 38. GIT-TFS Plugin for Git command-line git tfs clone http://tfs:8080/tfs/DefaultCollection $/Project git checkout -b story git commit -am "Progress" git tfs pull git tfs shelve "Shelveset Name" git tfs checkintool Allows you to use git for development when repository is TFS Note: Commits to TFS as one commit, even when you have committed multiple times: no need to rebase
  39. 39. GITHUB Popular Thriving Community Great Code Web Experience Organization Support Pull Requests Sophisticated Code Review Repository Wiki Issue Tracking Low Cost Web Api Team City integration
  40. 40. GITHUB INTEGRATION DEVELOPER EXPERIENCE track main repository pull request when ready for review request is verfied by Team City request starts code review easy to comment directly on code changes in GitHub GitHub provides email notifications on build status and code review ability to push branches to individual account to collaborate with team members
  41. 41. GITHUB INTEGRATION REVIEWER EXPERIENCE Pull Requests are checked by Team City; notifications in pull request comments Easily see if request will merge without conflicts Can use John Resig's Node.js module Pulley to rebase pull requests and close it
  42. 42. CONCLUSION Git is a well-designed version control system. Microsoft supports Git. We are using git locally with git-tfs right now. — GitHub offers a sophisticated repository service. Team City supports Git and GitHub. We could be using GitHub right about now.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×