Hello! Welcome to e-TAs, your on-line help for ECON 4676. So you want to learn how to use Github. In this e-TA, you will learn the intricacies and specifics of working with Github and strategies to keep your file version control under your control. The present issue focuses on the basic operations of Git
and Github
. The core material was extracted from tutorials at the BDEEP group at NCSA and Prof. Grant McDermott 1
When you begin a new coding project, you will want to create a new repository. This repository will grow to hold all of the important files for your project.
You can create a new repository by clicking the green “new repository” button on your github homepage.
Step 1: Name your repository Give your repository an accurate and concise name. You want the project to be recognizable! You can also add an optional description to summarize the goal of your project.
Step 2: Public or private Most repositories should be made public unless you have a specific reason to make it private. A public repository can be viewed by anyone but you can choose who can commit to it. Since it can be seen by others, it is possible to collaborate with others if you need help. A private repository can only be viewed by you and you are the only person who can commit to it, but you are able to manually add other collaborators as well. Private reposoitories are only available for paid accounts.
Step 3: Add a README Finally, select “initialize with a README”. You should only keep this unchecked if you are creating a repository from an existing repository.
Step 4: Licence The license dropdown allows you to select a license if you are sharing open source software.
Step 5: gitignore dropdown allows you to choose any file types that will not be committed
Congratulations! Now you have created your own repository! Once you have a repository on GitHub, here is how you link it to your computer. This section is more code based side, with the specific commands you will need to use to get version control working for you!
First you need to get your repo url
Open up your command line tool, and write git clone
with the url you copied. For example:
Now the repo is in your local computer. You can see for example your commit history (hit spacebar to scroll down or q to exit).
or what has changed?
to add files
Stage (“add”) a file or group of files.
You can use wildcard characters to stage a group of files (e.g. sharing a common prefix). There are a bunch of useful flag options too:
Commit your changes.
Pull from the upstream repository (i.e. GitHub).
Push any local changes that you’ve committed to the upstream repo (i.e. GitHub).
origin
is a shorthand name for the remote repository that a project was originally cloned from. and master
the branch we are pushing to.
Forking is going to be the way to contribute to my lectures, e-TAs, etc, and get those precious participation points
In fact, if you fork a repo then you are really creating a copy of it.
Forking a repo on GitHub is very simple; just click the “Fork” button in the top-right corner of said repo.
This will create an independent copy of the repo under your GitHub account.
A is notified and can then decide whether to merge B’s contribution with the main project.
Incomplete Section: the best pull requests for this section get some bonus points =)
Q: What happens when something goes wrong?
A: Think: “Oh shit, Git!” - Seriously: http://ohshitgit.com/.
Q: What happens when something goes horribly wrong?
A: Burn it down and start again. - http://happygitwithr.com/burn.html - This is a great advantage of Git’s distributed nature. If something goes horribly wrong, there’s usually an intact version somewhere else.
If you have comments, suggestions, etc. please submit a pull request ;).↩