By the end of this lesson, you will be able to:
- Make a new github repo
- Edit README.md
- Fork and clone a repo
- Make changes, commit and push changes
- Submit a pull request
- Submit an issue
Github has special terms for their parts and workflows (forking, pushing, pulling and cloning). These are all basically related to storing files and moving them around. A repo (or repository) is like a folder.
Go to github.com, sign in (or sign up if you haven't already). Then go to your profile page (e.g. Lisa's is https://github.com/ljcohen, then select "New repository".
Name can be something like 'super_awesome_killifish_data', whatever is fine! Be sure to check the 'initialize with Readme' box.
Your repo should look something like this:
Click on the pen icon to edit README.md to edit the file. Here is a markdown cheat sheet
Add some formatting things, like hyperlinks and lists:
- apple
- bananas
- llamas
or images:
Get your GitHub repository url, e.g. https://github.com/ljcohen/super_awesome_killifish_data.git
Then, on your local laptop or remote UNIX machine, navigate to a directory where you would like to copy the files. Then type:
git clone https://github.com/ljcohen/super_awesome_killifish_data.git
This will create a new directory named super_awesome_killifish_data
and download the contents to your coputer or machine. In this case, there is only a single file README.md
. If you're on your local computer, open up your Finder and navigate to the directory to see the files. Now you can add files and they will be version controlled!
Now we will do something else. Let's say we made some important files during an NGS course. Let's all collaborate and decide what those files are. I created a repository of files. Perhaps you would like to modify this collection. Click on this link to go to this github repo and fork it.
This will fork the repository into your account. Make sure that you can see it listed as a repository on your profile. You have just created a copy of all the files from my repo and brought them into your profile!
Now, clone this new repository by copying the url like you did before and typing.
git clone https://github.com/youraccountname/ngs2016_important_files.git
When you clone a repository, you are creating a directory (folder) onto your home computer by this name. Locate this ngs2016_important_files
directory on your local computer. Make some changes (any changes!), such as copying a random file(s) or editing any existing files. What are some important files you have from this course that you would like everyone else to have? Perhaps you would like to propose changes to the README.md
file?
Once you have made these changes, commit and push these changes to your github profile.
First, on your local terminal, type:
git add --all
git checkout
This will check and display a list of the changes you've made. Then type:
git commit -m "this is a special message from Lisa"
This will commit the changes made and get them ready for uploading.
Now upload with this command:
git push origin master
Open your profile on the web and you should see the files!
Your repo may get behind other changes I'm making or others are making. We will now make sure your repo is up-to-date. To see the address of the remote repo:
git remote -v
You should see your own url. To add my url, go to my repo and copy the clone url:
git remote add upstream https://github.com/ljcohen/ngs2016_important_files.git
git remote -v
Now you should see my repo url as upstream and your url as origin. To make your repo up-to-date, type:
git pull upstream master
Files should download if there were any changes made to the web version of the repo.
It's great that you have these changed files in your repo! Now you want to share with your collaborators so everyone has the same version of the files collection in their repo. Go to your repo and click on submit a pull request:
You will see two comparisons between the master and your repo. There shouldn't be an conflicts, so click on 'Create pull request':
This will make a request for your changes to be pulled into and merged with the original repo.
Sometimes we have issues with software, find bugs or have questions, and want to be able to communitcate with the authors. Github has this great feature where you can file issues, and makes them public records: nvbn/thefuck#440
Practice by creating an issue with this repo:
Github repos contain static documents. Github suports rendering of .ipynb
, .pdf
, .Rmd
, .md
, .rst
files. (and probably many more...) This is a great way to post files and share with your boss, colleagues, or just store documents for yourself. This way, all you have to do is share the url link.
-
git add script.txt
will add the file script.txt into your local git repository. -
git commit -am "some message"
will save the latest version of the script into your local git repository -
git push origin
will send your committed versions to github, where they will be safe. -
git log
will show you your history. -
git pull
will update your command-line repository from your GitHub account. -
git status
will show what files have been changed
- Contributing to open-source software project on github, khmer
- ANGUS 2016 github lesson
- Lab meeting on github
- Sign up for private repos for education
- Software Carpentry, github for novices lesson
- Intro git, halfday workshop at UC Davis
- Github for classrooms
- Issue pushing large files to github, how to solve