Difference between revisions of "John's GitHub page"

From ProgClub
Jump to: navigation, search
(Adding Links section...)
(adding notes about fork syncing, tools, etc...)
Line 1: Line 1:
 
OK. Hi there. I'm [[User:John|John]]. So recently I've made some modifications to code that is hosted on [https://github.com/ GitHub], as you can see in [https://github.com/jj5 my account]. I'm new and still learning the process, so here's what I've figured out:
 
OK. Hi there. I'm [[User:John|John]]. So recently I've made some modifications to code that is hosted on [https://github.com/ GitHub], as you can see in [https://github.com/jj5 my account]. I'm new and still learning the process, so here's what I've figured out:
 +
 +
= Tools =
 +
 +
== Git ==
 +
 +
So the git command-line tool is pretty much essential. Install on Debian with: apt-get install git
 +
 +
== SourceTree ==
 +
 +
[https://www.sourcetreeapp.com/ SourceTree] comes recommended as a GUI for beginners and pros alike. Install on Debian with: oh, dear. It's not a Linux tool. Nevermind.
 +
 +
= Syncing a fork =
 +
 +
== Configure your upstream remote ==
 +
 +
If you haven't already done so:
 +
 +
# list current remotes: git remote -v
 +
# add an upstream remote if there isn't one: git remote add upstream git@github.com/orig-owner/orig-repo.git
 +
# verify your remotes: git remote -v
 +
 +
== Fetch from upstream repository ==
 +
 +
# fetch upstream branches/commits: git fetch upstream
 +
 +
== Switch your to master ==
 +
 +
# check out your fork's local master: git checkout master
 +
 +
== Merge upstream/master to local master ==
 +
 +
# sync your local master with upstream: git merge upstream/master
 +
 +
== Push your local master back to your fork on GitHub ==
 +
 +
# push your fork: git push origin
  
 
= Submitting a patch via GitHub =
 
= Submitting a patch via GitHub =
Line 63: Line 99:
 
* [https://help.github.com/articles/creating-a-pull-request-from-a-fork/ Creating a pull request from a fork]
 
* [https://help.github.com/articles/creating-a-pull-request-from-a-fork/ Creating a pull request from a fork]
 
* [https://stackoverflow.com/questions/284514/what-is-a-git-topic-branch What is a git topic branch?]
 
* [https://stackoverflow.com/questions/284514/what-is-a-git-topic-branch What is a git topic branch?]
 +
* [https://help.github.com/articles/configuring-a-remote-for-a-fork/ Configuring a remote for a fork]
 +
* [https://help.github.com/articles/syncing-a-fork/ Syncing a fork]

Revision as of 13:44, 27 February 2017

OK. Hi there. I'm John. So recently I've made some modifications to code that is hosted on GitHub, as you can see in my account. I'm new and still learning the process, so here's what I've figured out:

Tools

Git

So the git command-line tool is pretty much essential. Install on Debian with: apt-get install git

SourceTree

SourceTree comes recommended as a GUI for beginners and pros alike. Install on Debian with: oh, dear. It's not a Linux tool. Nevermind.

Syncing a fork

Configure your upstream remote

If you haven't already done so:

  1. list current remotes: git remote -v
  2. add an upstream remote if there isn't one: git remote add upstream git@github.com/orig-owner/orig-repo.git
  3. verify your remotes: git remote -v

Fetch from upstream repository

  1. fetch upstream branches/commits: git fetch upstream

Switch your to master

  1. check out your fork's local master: git checkout master

Merge upstream/master to local master

  1. sync your local master with upstream: git merge upstream/master

Push your local master back to your fork on GitHub

  1. push your fork: git push origin

Submitting a patch via GitHub

Fork the upstream repository into a project in your account

  1. go to GitHub
  2. login
  3. navigate to the project repository you want to fork
  4. click 'Fork' on the top right

Clone your fork

  1. open a terminal on your workstation
  2. change dir to your github directory (I use /home/jj5/repo/git/github/jj5)
  3. clone your fork (using SSH) with: git clone git@github.com/jj5/MyProject.git

Make a topic branch in your fork

You can read about what a topic branch is.

  1. open a terminal on your workstation
  2. change dir to your github fork (e.g. /home/jj5/repo/git/github/jj5/MyProject)
  3. create a branch with: git branch branch-name
  4. switch to your new branch: git checkout branch-name

Note: you can create a branch and check it out with one command: git checkout -b branch-name

Question: is 'switch' the correct verb for changing between branches?

Make your changes

So edit files, add files, etc.

Tell git about new files

If you've added files include them in git with: git add file.name

Commit your changes on the topic branch

To commit your changes: git commit -a -m 'What you did...'

Push your changes into your fork at GitHub

To push your topic branch upstream: git push --set-upstream origin branch-name

Create a pull request

  1. go to GitHub
  2. login
  3. navigate to your fork in your account
  4. in the top left select your topic branch for the Branch drop down
  5. click 'New pull request'
  6. the 'base fork' should be the project you forked from that you wish to contribute to
  7. the 'base' branch is the branch you want to merge with (probably 'master'?)
  8. the 'head fork' is where your proposed changes are (i.e. in your fork)
  9. the 'compare' branch is the branch that has your changes (i.e. your topic branch)
  10. add a message, check your changes, and submit your way to victory!

Links