Git/GitHub Tutorial for SAAO

Think of a question you have about git or github.

Prelimaries

1. Do you have a github account?
If not, go to http://www.github.com and create an account.

2. Do you have git?
If not, download it via your favorite method.

Using Github

Go to https://github.com/saltastro/saao_git_tutorial and fork the repository

Once forked, click on the directory 'questions'

Now click on the button for new file

Create a new file named q_[topic].txt where [topic] is replaced with the subject of your qeustion. EEnter it into your question using the following syntax:

 Question: What is the address of the repository 

And then save the file

Finally make a pull request for this new file

Congrats you have now added to the SAAO git tutorial repository!

Using Git

Download a local copy of your forked proposal

 git clone https://github.com/crawfordsm/saao_git_tutorial.git

This link should be copied and pasted from the link from the github page for your forked repository.

Update your local repository so you can see everyone else's questions. This will require you to pull from the reposity that you forked from.

 git pull https://github.com/saltastro/saao_git_tutorial.git 

Select a quesiton that you think you might be able to answer (either your own or someone else's). Once you have selected it, create a new branch that has the name of that topic

   git branch repository
 

Once created, checkout the new branch

   git checkout repository 

You should be now on that branch

Next update the file with your answer

 
Question: What is the address of the repository ?

Answer: https://github.com/saltastro/saao_git_tutorial.git

Add your changes. This stages all of your changes to be committed

   git add .
 

Comit your changes. This saves the changes that you have made. You can also add a message when you make the commit

   git commit -m 'Answer repository question '
 

Your changes will now be saved to your local repository

If you want to save them to your repository on git hub, you will have to 'push' the changes to there

   git push origin repository 
 

Now check out your github repository and see your changes. If your answer is a good one and you want to share add it to the main repository, go ahead with a pull request.

Congratulations! You have just initiated a pull request from your own local branch.

Merging the Pull Request

Check out one of the other tutorials under resources to see what else you can do!