Git and Github Basics of command line Downloading, installing, configuring Git The workflow with Git Main Git tools Configuring remote (Github) connections Forking and cloning a repo on Github Contributing changes to a public repo
takes a peer-to-peer approach to version control, as opposed to the client-server approach of centralized systems. Rather than a single, central repository on which clients synchronize, each peer's working copy of the codebase is a bona fide repository. " http://en.wikipedia.org/wiki/Revision_control 2- It's got tons of documentation and support 3- It's open source 4- It's fast 5- It doesn't require any network connection Why Git is the most popular
full history of a document. Once changes are committed, it is not possible to change the old version. http://en.wikipedia.org/wiki/Git_(software) What exactly does Git do?
Git. It has paid and free memberships. Free ones require that you only have open source (visible to everyone) projects. It offers a variety of social networking functions, like following and RSS feeds, based around repositories. http://en.wikipedia.org/wiki/Github What does Github do?
real information: [text in brackets] Output expected in the command line: indented purple text Practice activity- work along! white background Using these Slides
one level up ~ your home directory cd [place] change directory to [place] clear clear terminal screen diff [name1] [name2] display differences between files help lists possible commands ls lists contents of present directory mkdir makes a directory (folder) pwd lists present working directory rm [file] removes (deletes) [file] touch [name] creates a file called [name] Bash command line basics
Email should match one on your Github account. Name will attach to commits- be professional. Confirm : git config --global user.email git config --global user.name Or view config file at ~/.gitconfig http://git-scm.com/docs/git-config Configure Your Git Account at the Command Line
commit -m " " git status The Git Flow what it does initializes a repo stages changes commits changes what's up, git? This is the general workflow in Git.
place to make a new directory. Documents or Desktop, perhaps. Then, make the directory. cd [~/Documents] mkdir DoingGitStuff Navigate into the new directory cd DoingGitStuff Initialize it as a Git repository git init Create a file touch coolfile.txt See what's up with Git git status Oh, you have an untracked file! Let's track it. git add coolfile.txt And save these changes git commit -m "Add new file" Sweet!
polite Short : 50 characters or less Begin with active, present-tense verb GOOD: "Fix the js bug causing login errors" "Update README.md" "Add support for packager to build installers" Best Practices: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html Commit Messages
"so many php errors" "went and fixed the pager, added some new stuff to the headings, put that photo of a bulldog in there" http://www.commitlogsfromlastnight.com/ Commit Messages
with appropriate names, to work on features. • Merge successful feature branches back into Master. • Remote and local branches must be created independently. Give them the same names! • You work on correct branch locally, but remote only matters when you're pushing. • Merging branches is potentially frustrating. Branches
branch master *feature do some work git push origin feature Branch Creation + Movement what branch am I on? create a feature branch go to feature branch what branch am I on? ... push to remote feature branch
are available git branch Ah, you only have a master, which was created automatically at the time of your first commit. Let's assume you're about to try a cool new thing in your code that may not work. You should put it in its own branch until it's complete so the master branch keeps working well. Create a new branch called feature. git branch feature Did it work? Let's see what branches are available now. git branch Now you have two branches listed, right? Good. Let's switch to working in the feature branch. git checkout feature Cool! Now do your risky work (or just make changes to coolfile.txt). We'll later merge this branch back into master.
the place you specify, whether that's a commit or a branch (which is shorthand for "the last commit in this particular branch") . Example: git checkout feature git checkout 50edd9bc416048059ef166d git checkout
feature branch back into Master. You must be on master to do the merge. git checkout master git merge feature -m "Implement new feature" http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging Merging
like and save the file. Add and commit the change git add coolfile.txt git commit -m "Add excellent data to coolfile" Check status git status # On branch feature nothing to commit (working directory clean) Looks good! Now go back to master branch git checkout master And merge the feature branch into master git merge feature Updating 4308a22..338be7b Fast-forward coolfile.txt | 1 + 1 file changed, 1 insertion(+) Cool!
the same part of a file. Fix by looking at both versions of the file and deleting one set of conflicting changes. Open the file with a text editor or git mergetool http://stackoverflow.com/questions/161813/how-do-i-fix-merge-conflicts-in-git Merge Hell
Past commits look like this: commit 50edd9bc72e5416048059ef166d554e3cd85b4dd Author: cherimarie <[email protected]> Date: Sun Feb 24 18:18:54 2013 -0800 Copy the SHA (secure hash algorithm) of the commit you'd like to roll back to and checkout: git checkout [50edd9bc72e5416048059ef166d554e3cd85b4dd] Rolling Back Repo to Earlier State
meaningless information from git git cherrypick- transfer only some commits to new branch git rebase- powerful tool, can change commit history, potential for mayhem http://git-scm.com/docs Git Extras
changes in files on your machine. You can work in different branches to experiment safely with ideas that may break your project. You can merge branches together when they're good and roll back commits when something goes badly. Summary
contributor who seems awesome, Follow them. Ask the person next to you for their Github address. Go visit their page. Maybe follow them, too! Come visit me at github. com/cherimarie and we can be friends. Be Social
as local one (DoingGitStuff) 2- Copy HTTPS address of new repo 3- In Terminal: cd DoingGitStuff git remote add origin [pasted address] git remote git push origin master *origin is what you are naming connection *master is the remote branch you're sending to Configure Remote Connections
and password every time you push or pull, unless you have a credential helper. Very easy to set up. SSH: Good for secure computers. You generate a SSH key locally that identifies your machine to Github. Follow github tutorial to set up, not terribly hard. SSH or HTTPS Remote?
repo 3- Clone the repo so it's available locally 4- Do some work! Fix bugs, add features. 5- Add and commit work to your local repo 6- Push work back to your forked repo 7- Send a pull request to original owner 8- Add "Contribute to open source projects" to your resume Working on Open Source Projects
2- Fork by pushing the "fork" button 3- Copy HTTPS address of your fork of repo 4-Clone repo to local machine git clone [pasted address] This copies the whole directory to your local machine, initializes it as a repo, and builds in the remote connection! 5- Open GitResources.docx in a text editor, add something to it, save
to local repo git add . git commit -m "[comment]" 7- Push to your Github repo git push origin master 8- Send pull request to CheriMarie From your repo's page on Github, "Pull Request" button, fill out title and description, "Send" 9- Win!
to your local ones so you can push and pull changes. You know how to fork and clone cool repos so you can work on open source projects, plus send pull requests back to the original authors to have your changes incorporated into the main project. Summary
time and practice to master. There are ample resources available to help you out- take advantage of them. When Git is supplanted by the next hot thing, be ready to learn an entirely new system! I'm Cheri Allen, @CheriMAllen on Twitter. I'd love to hear your feedback about this slidedeck and what your favorite octocat is! Wrap Up