140 likes | 315 Views
Git – An introduction. August 28, 2013 ASU SoDA. What is Git ?. Version Control Free and Open Source Distributed. !=. http://git-scm.com/downloads/logos , https://github.com/logos. Without Version Control. Two programmers, one program Changes collide Harry’s changes are lost
E N D
Git – An introduction August 28, 2013 ASU SoDA
What is Git? • Version Control • Free and Open Source • Distributed != http://git-scm.com/downloads/logos, https://github.com/logos
Without Version Control • Two programmers, one program • Changes collide • Harry’s changes are lost • This is no good… http://svnbook.red-bean.com/en/1.7/svn.basic.version-control-basics.html
With Version Control Instead of overwriting, just combine the changes! Git(mostly) uses algorithms to merge files – with no input from the programmers!
How to Git: • Files go in a repository • Usually, there is a central copy of the repository stored somewhere like GitHub • Users may clone the repository • Want to see the latest changes from the central copy? Fetch the repository. Pull to apply the changes to your working copy. • Want to send your changes to the central copy? Push your repository.
Making Changes • When you’ve edited files, and are happy with the changes, stage the changes and committhem. • A commit is a file containing a list of changes. It’s labeled with a universally unique code to tell it apart from other commits. • Commits are relatively permanent. They can be undone, but it’s far easier to just double check before committing.
What about those conflicts? • If you try to push or pull with an out-of-date copy, you will need to merge. • Merge combines the changes of two versions, usually automatically. • If there were unsolvable conflicts, Git will show you both versions in a text editor and let you decide. https://gist.github.com/zeroasterisk/4265044, http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging
Branches • Git allows branching, multiple parallel copies of one program • Branches can be edited and committed to independently. Usually used to work on separate features or bugs • Unite two branches with merge. http://hades.name/blog/2010/01/22/git-your-friend-not-foe-vol-2-branches/
Rebasing? • Rebasing reaches “back in time” and combines branches into one linear branch • Makes the Git history easier to read, but destroys information. BE CAREFUL http://hades.name/blog/2010/03/03/git-your-friend-not-foe-vol-4-rebasing/
Other useful things • Commits must be tagged with messages explaining what they are doing • reset reverts all your working copy’s changes to the original state of the local repository • stash holds changes aside so they’re not committed immediately • diff lets you look at the changes made by each individual commit …and many, many more!
Git Etiquette • Differs from place to place • For our repositories: • If the program compiles, builds, and runs, don’t commit changes that break that • Messages should be present (imperative) tense: First Line 50 Chars Max, Capitalized, is Subject Detailed explanation if necessary. Lines less than 72 chars longand written in normal English.
More questions • Where do I get it? Where are GUIs for it? Where are SoDA’s repositories? What is GitHub? Something else formatted like a question?Will post more on the SoDA website.