18
Git & Github for .NET Development JP Toto VP for Application Development Cognis IT http://www.cognisit.com [email protected] @jptoto Fill this space with whatever you want (graphic, logo, whatever)

Nyc Code Camp 2010 Git And Github

  • Upload
    jptoto

  • View
    1.876

  • Download
    2

Embed Size (px)

DESCRIPTION

Presentation I did at NYC Code Camp about using Git and Github for .NET development on Windows.

Citation preview

Page 1: Nyc Code Camp 2010 Git And Github

Git & Github for .NET Development

JP TotoVP for Application Development

Cognis IT http://[email protected] @jptoto

Fill this space with whatever you want (graphic, logo, whatever)

Page 2: Nyc Code Camp 2010 Git And Github

What we’re gonna cover

• Short history of Git• Differences between Git & Subversion: What’ s a DVCS• Make a repository and perform operations on it• How to integrate Git & Subversion• Short jog through GitHub

URL For all Links!

http://bundl.it/MjYxNjM

Page 3: Nyc Code Camp 2010 Git And Github

History of Git

In 2005, the relationship between the community that developed the Linux kernel and the commercial company that developed BitKeeper broke down, and the tool’s free-of-charge status was revoked. This prompted the Linux development community (and in particular Linus Torvalds, the creator of Linux) to develop their own tool based on some of the lessons they learned while using BitKeeper.

Ohai! BitKeeper screwed us so I think I’ll write my

own DVCS. Natch.

Page 4: Nyc Code Camp 2010 Git And Github

What makes Git different?

Typical SCMs use changes based on file differences:

Page 5: Nyc Code Camp 2010 Git And Github

What makes Git different?Git thinks of each commit of a snapshot, doesn’t re-save files that weren’t modified – only pointers.

Page 6: Nyc Code Camp 2010 Git And Github

The Staging Area

Page 7: Nyc Code Camp 2010 Git And Github

What does that mean for us?

• Almost all operations are local.• Very cheap branching & merging (more in a bit).• Ability to work offline.• Entire repository and all its history is with your local copy.

Page 8: Nyc Code Camp 2010 Git And Github

Installing Git

Msysgit

Tortoise GIT

Git Extensions for Visual Studio

$ git config --global user.name “Joe Smith" $ git config --global user.email “[email protected]"

Page 9: Nyc Code Camp 2010 Git And Github

You first repo!.gitignore

• git init• git add• git commit• git status• .gitignore

objbin_ReSharper.**.csproj.user*.resharper.user*.resharper*.suo*.cache*~*.swp

Page 10: Nyc Code Camp 2010 Git And Github

Some other operations

• git commit –m “Message”• git commit –amend• git reset HEAD file.txt (Remove from staging area)• git checkout -- file.txt (Dangerous! File is overwritten)• git log

Page 11: Nyc Code Camp 2010 Git And Github

Branching & MergingVery FAST! Only uses pointers instead of copying whole files, folders, and projects.

Git encourages lots of branching / merging.

$ git branch <new branch>

$ git checkout <new branch>

$ git merge

$ git branch –D <branch_to_delete>

$ git mergetool

Page 12: Nyc Code Camp 2010 Git And Github

Branching & Merging

Page 13: Nyc Code Camp 2010 Git And Github

Rebasing

Page 14: Nyc Code Camp 2010 Git And Github

Remotes

$ git remote

$ git remote add origin git://github.com/jptoto/project.git

$ git fetch / git pull

$ git push

$ git remote show origin

Page 15: Nyc Code Camp 2010 Git And Github

Github

Page 16: Nyc Code Camp 2010 Git And Github

Git & SVN• Use Git as a valid SVN client• Keep all the client features of Git

• Local branching & merging, staging, etc• Great way to sneak it into your corporate environment >:-)

$ git svn [command]$ git svn clone svn://path.to.svn.repo

Caveats:1.Keep history as linear as possible, avoid rebasing2.Don’t re-write your history and do another push3.If you’re on a mixed team, makes sure you’re using SVN server

Page 17: Nyc Code Camp 2010 Git And Github

What if I’m used to SVN?

$git clone [url] $svn checkout [url]

$git pull $svn update

$git init $svnadmin create “repo”$git add . $svn import file://repo$git commit

$git merge [branch] $svn merge -r 20:HEAD http://url/branches/branch

Page 18: Nyc Code Camp 2010 Git And Github

Helpful References

• http://progit.org (CC book by Scott Chacon)• http://www.gitready.com (git tuts)• http://gitcasts.com/ Screencasts about Git• http://git.or.cz/course/svn.html Git-SVN hints