Introduction To Git Presentation
The best way learn git is to use it. If you've never used git before, I recommend beginning with this short, interactive tutorial: Try Git
Now that you have some idea of what the commands are and the basic workflow, let's do some real world examples.
Local Configuration
There are alot of configuration options in git. The basics are listed below but you'll find you probably want to add more.
-- Link to Configuration Options
git config --global user.name my name”
git config --global user.email “[email protected]”
Setup a Github Account
Github is a hosting service for git repositories. Even if you don't use github as your standard remote, I recommend setting up an account. Sign Up For Github
If you are a student, you are likely eligible for a free "Micro Plan". This gives you five private repositories for 2 years. Apply here.
Our practice will follow the Github Bootcamp, with a few modifications.
-
If you are using your hydro computer, git is already installed (/usr/bin/git) and we've already taken care of the basic configuration, so you can skip to #2. If you are on another machine, installation is pretty easy and is outlined in the link above.
-
Everyone needs a "Hello-World" repository. Follow the steps in the Create A Repo tutorial to create your own "Hello-World".
If you are having trouble pushing to your github repository check to make sure you are pushing to the ssh address, rather than https address. You will likely need to setup your ssh key here.
Once you have your ssh keys setup, try pushing to the ssh repo address[email protected]:$USER/hello-world.git
You can change the remote address using:
git remote set-url origin [email protected]:$USER/hello-world.git
Bonus: Now that you have that dialed, try repeating those steps for a project you've been working on.
-
Follow the steps in the tutorial to fork and clone the Spoon-Knife repo.
####The assignment
a. Fork the git_traning, VIC, and DHSVM repositories.
b. Now clone the your fork of the git_training repository to your local machine. i.e.:
git clone [email protected]:$USER/git_training.git *Note: If you get an ssh error when you try to clone or fetch, check out Github's tutorial on [how to setup ssh keys](https://help.github.com/articles/generating-ssh-keys).*
c. Create a branch your local copy of the repo, something like
git branch joes-example-branch
d. Checkout your branch
git checkout joes-example-branch
Note: c and d can be done as a single step as
git checkout -b joes-example-branch
e. Add a file to your repo (i.e. my_new_file.txt). The commands you'll need for this are:
touch my_new_file.txt git add git commit # Don't for get a good commit message
f. Push your changes to your Github fork.
git push origin joes-example-branch
e. Submit a pull request to UW-Hydro. This is done from your Github Repository Page.
-
Not mandatory but you can follow an organization (i.e. UW-Hydro) or a person (i.e. Joe Hamman if you want to stay tuned to ongoing developments on github
References and Links: