Repo for learning Github - used at our hacknights
You and a bunch of civic hackers want to work on a project together. The project you want to work on is already on Github, such as this. You are new to this social coding/collaboration thing and you want to make changes to a project.
-
Make a Github account.
-
Visit the Github project on a browser.
-
Open the file.
-
Make a change. Because you are not a collaborator, it will "fork" a copy of the repo. This means that you are making a copy of the project on Github and it's going to be associated to your account.
-
Submit a pull request. By doing so, you are asking the maintainers of the project to review your changes, and that you are requesting for them to merge it back into the repository that they are maintaining.
-
A collaborator on Github will then review the changes. They will either accept the changes, or give advice as to improve the changes even more before accepting the changes.
-
Install Github for Mac (or Windows)
-
Visit the project (such as
codeforprinceton/learnGithub
) via the browser and pressFork
. This will make a copy of the repository and will store it under your account. -
Go to your fork of the project on Github. If you followed step 2, you will have it under
https://www.github.com/<YOUR_NAME>/learnGithub
. -
Click "Clone in Desktop" on the right.
-
Make changes using a text editor (like Vim, Emacs, Atom, Sublime, etc.).
-
Once you are done with the changes, go back to Github for Mac, and make sure you are under the "Changes" tab.
-
Commit your changes by adding a summary and pressing
Commit
-
Press
Sync
to push your changes to your remote copy. -
Press the "Pull Request" icon (at the left of "Sync")
- Install
hub
. See: https://hub.github.com/
a. You want `hub` to be used when you use `git` in the command line.
You can do that by editing your `.bashrc` or `.bash_profile` in
the directory and adding the line `alias git=hub` using a text
editor.
b. Save your changes.
c. Go back to the terminal and let it know about the change you've
made: `source ~/.bash_profile` or `source ~/.bashrc` if you've
made the changes there.
- Change to the directory that you want to save the project to:
a. `pwd` to list the current working directory.
b. `ls` to list the files in the current working directory.
c. `cd <some_directory>` to change the directory to `some_directory`
-
Clone the repo:
git clone codeforprinceton/learnGithub
-
Check to see which branch you're in via
git branch
-
If you're in the right branch, you can fetch the most recent changes and merge it into your local copy of the branch through
git pull
-
Make your changes.
-
git status
to see all your changes. -
Stage your changes:
git add <name_of_file_you_changed>
git add .
is useful if you want to add multiple files. (The "dot" refers to the current directory).
-
Commit:
git commit -m "my commit message"
-
Fork the repository, which will make a copy of the project and save it under your account on Github:
git fork
-
Push to your new remote:
git push <YOUR_GITHUB_NAME>
-
Make a pull request.
git pull-request "title of the pull request" -h <YOUR_GITHUB_NAME>:master -b codeforprinceton:master -f
-h
stands forhead
. The argument of it is where you want to take changes from.-b
stands forbase
. The argument of it is where you want changes to be applied.-f
stands forforce
. Useful for preventing errors. Without it you might get an error saying something likeAborted: 1 commits are not yet pushed to origin/master