Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
Some "rules"
Tell us about yourself.
Version control allows you (and your team) to do two powerful things
Mistakes happen. Wouldn't it be nice if you could see the changes that have been made and go "back in time" to fix something that went wrong?
Create anything with other people, from academic papers to entire websites and applications.
Examples: CVS, SVN
One central server, each client (person) checks out and merges changes to main server
Examples: Git, Mercurial
Each client (person) has a local repository, which they can then reconcile with the main server.
Goals of Git Design
Git installation instructions on GitHub
Go to home directory
In the bash terminal:
cd ~
Create a "working directory"
mkdir my-first-repo
cd my-first-repo
Initialize repository with Git
git init
git status
Create a new hello_world.txt file in your new folder
Check repo status
git status
Tell Git to track our new file
git add hello_world.txt
git status
File is now tracked by Git
Open hello_world.txt and add some more text
git status
Stage and commit the change
git add hello_world.txt
git commit -m "First commit. Added hello world to repository."
How is this all different than just saving a file?
git log
commit [HASH HERE]
Author: Your name
Date: [DATE HERE]
First commit. Added hello world to repository.
If you haven't committed yet
Open hello_world.txt and add some new text
git status
git checkout hello_world.txt
git status
Look at hello_world.txt. Your changes are gone.
Open hello_world.txt and add some new text
git add hello_world.txt
git reset HEAD hello_world.txt
git checkout hello_world.txt
Look at hello_world.txt. Your changes are gone.
Open hello_world.txt and add some new text
git add hello_world.txt
git commit -m "Changing and committing some lines"
git log --pretty=oneline
git revert [HASH]
Look at hello_world.txt. Your changes are gone.
Create new file my_new_file.txt
git add my_new_file.txt
git reset my_new_file.txt
Create new file my_other_file.txt
git add my_other_file.txt
git commit -m "Add new file"
Manually delete your file
git rm my_other_file.txt
git commit -m "Remove file"
Create a new branch called new-feature
git checkout -b new-feature
Add new lines to hello_world.txt
git add hello_world.txt
git commit -m "Adding changes for new feature"
See all branches. Branch with * is active
git branch
Switch to master and look at hello_world.txt
git checkout master
Switch to new-feature and look at hello_world.txt
git checkout new-feature
Switch to master and merge changes
git checkout master
git merge new-feature
Rebase is another option, but will not be covered in this workshop
Change first line in hello_world.txt in master branch
git add hello_world.txt
git commit -m "Changing first line on master"
Switch to new-feature branch
git checkout new-feature
Open hello_world.txt and change first line
git add hello_world.txt
git commit -m "Changing first line on new-feature"
Merge from master into new-feature
git merge master
You will be notified of a conflict. Go to the file and fix the problem. Then commit your edits.
While a README isn't a required part of a GitHub repository, it is a very good idea to have one. READMEs are a great place to describe your project or add some documentation such as how to install or use your project. You might want to include contact information - if your project becomes popular people will want to help you out.
cd ..
mkdir hello-world
cd hello-world
git init
git remote add origin https://github.com/USERNAME/hello-world.git
git pull origin master
Edit the ReadMe file
git add README
git commit -m "Create readme file"
git push origin master
Go look at your github repo online
If you're working with a team, make sure that you have everyone's changes before pushing your own changes.
git commit -m "My latest commit"
git pull origin master
git commit -m "Fixing merging conflicts"
git push origin master
How to manage pull requests is out of the scope of this short workshop, but you can learn more from the Github Collaborating Tutorials
Please complete the GDI survey for this workshop.