A safe place to experiment with git & github in a group setting
This is a playground open to anyone looking to practice using git & github in a group project. Feel free to make any and all changes as you test your github chops. One caveat, we ask you please do not change the main readme unless you are making an improvement (P.S. please help the next person and make improvements).
To reiterate this repository is to get people (you!) comfortable with using github do not be scared to try things out!
- [Clone] (https://help.github.com/articles/cloning-a-repository/) from your command line
git clone https://github.com/Data4Democracy/github-playground.git
. Optional: Fork the repo first. - Move to main directory `cd github-playground``
- Check your status
git status
Should see "On Branch Master" "Your branch is up-to-date with 'origin/master'" - Create and checkout a branch to work from:
git checkout -b <branch_name>
EX:git checkout -b training-branch
You can see all branches by typinggit branch
. Note: we are using training-branch in this example but by the time you follow these instructions someone may have already createdtraining-branch
you should create a unique branch. - Read about git branching and merging
- Make a change to an existing file or create a new file and save.
EX: echo "print("hello")" > hello.py
- Check status of your change with
git status
. Your file should show up under "Untracked Files" EX:hello.py
or whatever file you created. - Add file to changes
git add <filename>
orgit add .
(adds all untracked files -- CAREFUL use with caution) EX:git add hello.py
- See exactly what changes are staged
git diff --cached
(orgit diff
if files are not yet staged) - Commit your changes `git commit -m "Hey this is my first commit" Read about how to write good commit messages.
- Check your remote
git remote -v
(if you started by cloning a repo from github origin should already be set) - Push your changes it to the remote server by typing
git push <remote-name> <your-branch>
EXgit push origin training-branch
- Open the repo in github and select your branch
- You should see [compare an pull request]https://help.github.com/articles/about-pull-requests/. This will bring up a summary of your changes and show you what branch you are merging.
- Edit your message and click submit. Now you should see your pull request show up in the pull requests tab!
- In a real project your PR may be discussed and reviewed. Stakeholders may suggest changes or updates and (hopefully) eventually your code will be merged!
- If you need to make changes to the code in your PR you can make the changes EX:
echo "print("hello good sir")" > hello.py
git diff
to check your changesgit add hello.py
to stage your changes- `git commit -m "More formal greeting"
- Do another
git push origin <branch>
and changes show automatically show up in the PR (No need to open another PR).
- If you need to make changes to the code in your PR you can make the changes EX:
This only scratches the surface of what is possible with git and github. Feel free continue to use this repo when you need to test out (or document for others!) more complicated workflow.
- Do not worry, we have all been there!
- Join #github-help channel on slack and ask for help.
- DM someone directly. Below users have volunteered to assist with github questions
- @bstarling
- Something was not clear or area you struggled with? Submit a Pull request (PR) or open an issue to help us improve!