GitHub: Difference between revisions

From John's wiki
Jump to navigation Jump to search
(Work, work...)
Line 15: Line 15:


== Make a topic branch in your fork ==
== Make a topic branch in your fork ==
You can [https://stackoverflow.com/questions/284514/what-is-a-git-topic-branch#284817 read about what a topic branch is].


# open a terminal on your workstation
# open a terminal on your workstation
Line 28: Line 30:


So edit files, add files, etc.
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 ==
== Commit your changes on the topic branch ==


To commit your changes: git commit -a -m 'What you did...'
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

Revision as of 06:15, 27 February 2017

OK. 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:

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