This is a rough template for what Scott Hanselman and I are teaching at the Women Who Code workshop on July 19th, 2016. All pull requests or issues to improve it are welcome :).
Disclaimer: This is still a WIP.
Table of Contents generated with DocToc
- Git, GitHub, and Contributing to Open Source
Head over to https://github.com/join?source=header-home and create an account.
Download git:
Or:
- Linux:
apt-get install git
- Mac:
brew install git
(requires you to have brew installed)
First you should tell git your name and email (You can set specific ones for different repositories if you wish.). So if you're Scott Hanselman, you'd do it like this:
git config --global user.name "Scott Hanselman"
git config --global user.email scott@hanselman.com
If you want to set up a default editor you can set it using:
git config --global core.editor vim
To see what configuration settings you have:
git config --list
Say you want to pull down Intel Snap, you would go to the github page, https://github.com/intelsdi-x/snap, click clone or download, pick HTTPS or SSH and copy the link. For HTTPS you can just add .git to the URL https://github.com/intelsdi-x/snap.git
.
After copying the link, go to the path you want to clone this to. For organization it is more clear when there are separate directories for different repo owners.
Go to GitHub and click the button new repository
. This is what mine looks like:
After clicking it you get to pick a title for your repo, decide if you want to make it public or private (this costs money), adding a license, and whether you want to have a .gitignore file.
After you create it, you can then go to your terminal to add either an existing git repo, or you can turn a directory into one.
Let's assume you haven't created your content yet.
You can either: Clone your new repository with the first link shown, so
git clone https://github.com/tiffanyfj/git-github-os.git
Or create a directory locally on your machine, create a directory with the same name that you used to create the GitHub repository. If you do it this way, you need to run
git init # this initializes your directory as a git repo
git remote add origin https://github.com/tiffanyfj/git-github-os.git
To see your remotes, you can run
git remote -v
Mine shows:
origin https://github.com/tiffanyfj/git-github-os.git (fetch)
origin https://github.com/tiffanyfj/git-github-os.git (push)
Make some files, say README.md. Add something to the README. Then add the file and make a commit. When creating this repository I created a directory on my machine in the path github.com/tiffanyfj/git-github-os
. Then I created this README and added some content.
git add README.md # if you do . instead of README.md, it adds all files in the directory
git commit -m "Initial readme commit"
git push -u origin master # if you cloned, you just need to do git push
Now if you go refresh your repository on github.com, your commit with your README.md should be there.
If you decide to make changes you can make a new commit with the changes by doing the previous git add
and git commit lines
or use git commit -am "Message goes here"
which does the two commands in one line. Then do a git push
.
Or if you want to add your new changes to the same commit you can do
git add README.md
git commit --amend --no-edit
git push --force # This is risky though because it overwrites what you had so make sure you know what you're committing.
Say you want to make changes on a branch other than master. This is common when wanting to separate different changes. If you want to have the exact
git fetch
: fetches the changes, but doesn't merge themgit pull
: doesgit fetch
andgit merge
. This results in an extra commit.git pull --rebase
: leaves your commits in a straight line without branches
Click the button at the top that says "Issues" and then the green button to the right.
Click the button at the top that says "Pull Requests" and then the green button to the right.
If the pull request (PR) is to fix an existing issue, you can reference it by #somenumber
, e.g. #2
. It's common to say "Fixes #somenumber" so when the PR is merged, it closes the corresponding issue.
Tip: Include the issue the PR fixes in the commit message and have descriptive messages.
Great websites for people who are new to coding/contributing to open source: