Skip to content

Latest commit

 

History

History
149 lines (130 loc) · 7.97 KB

7.0-collaboration.md

File metadata and controls

149 lines (130 loc) · 7.97 KB

7.0 Collaboration

  • forking
  • pull requests
  • issues
  • comparing changes
  • git fetch and git merge with multiple remotes
  • tagging issues in PRs

Often we will have changes on our remote that aren't on our local machine yet. There are a few ways we can get these changes pulled into our local machine effectively. First, git fetch will copy the remote changes into our git folder. git fetch on its own will copy all of the remote branches and stores them as remote tracking branches. We can see them with git branch -a. As an example, I'm going to fetch a repository I haven't updated in a few days. I have my fork, origin, and I have the upstream package that I forked that I named upstream. First I'll fetch upstream:

$ git fetch upstream
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 16 (delta 12), reused 8 (delta 6), pack-reused 0
Unpacking objects: 100% (16/16), done.
From https://github.com/yt-project/yt
   2fa8519dd..29005b829  master     -> upstream/master

We can see the commit references between master and upstream/master as 2fa8519dd..29005b829. We can look at all the commits between master and upstream/master with the log:

$ git log --oneline master..upstream/master
29005b829 (upstream/master) Merge pull request #2133 from brittonsmith/np16
9c38681a8 Provide list type to np.column_strack to fix numpy 1.16 future warning.
b63f72f13 Merge pull request #2132 from neutrinoceros/doc_dev_conda
1b944e26b Add documentation on how to install the dev version of yt within anaconda and without using pip
2fa8519dd Merge pull request #2122 from chummels/shea_fix
6b096c0e7 Simplifying logic with np.asanyarray()
2efd85bd4 Adding test for annotation of YTArray not in code_units.
07e0b6c0f Making sanitize_coords handle both YTArrays and numpy arrays.
e1765465b Making PlotCallback methods private.
6e595e992 Merge pull request #2128 from cphyc/fix/sphere_unit_mistake
d8bc026f0 Convert radius in right unit
dfa4a9e18 Merge pull request #2125 from ngoldbaum/debian-fix
6649bc658 run tests in temporary directory. fixes #2123
4530d035a Updating docstrings for annotate_marker and annotate_arrow.
7264d040a Updating callback tests to cover annotate_arrow and annotate_marker with multiple points.
eef928b13 Cleaning up sanitize_coord().
a5e8d92e7 Making annotate_arrow() work with multiple points.
12acb1644 Modifying sanitize_coord_system to handle multiple points.
26c70d1d0 sanitize_coord_system was returning just the first coordinate if coord_system == data; now return the full list

We can expand this a bit to see where HEAD is pointed.

$ git log --oneline -n 15 upstream/master
29005b829 (upstream/master) Merge pull request #2133 from brittonsmith/np16
9c38681a8 Provide list type to np.column_strack to fix numpy 1.16 future warning.
b63f72f13 Merge pull request #2132 from neutrinoceros/doc_dev_conda
1b944e26b Add documentation on how to install the dev version of yt within anaconda and without using pip
2fa8519dd Merge pull request #2122 from chummels/shea_fix
6b096c0e7 Simplifying logic with np.asanyarray()
2efd85bd4 Adding test for annotation of YTArray not in code_units.
07e0b6c0f Making sanitize_coords handle both YTArrays and numpy arrays.
e1765465b Making PlotCallback methods private.
6e595e992 Merge pull request #2128 from cphyc/fix/sphere_unit_mistake
d8bc026f0 Convert radius in right unit
dfa4a9e18 Merge pull request #2125 from ngoldbaum/debian-fix
6649bc658 run tests in temporary directory. fixes #2123
97054577d (HEAD -> master, origin/master, origin/HEAD) Merge pull request #2124 from zingale/master
4efd4b2ea update the docs to reflect the fact that rays are not ordered.

You can see the commit IDs in this log between master and upstream/master reflect those that were returned with the fetch command. We can also see that my fork, origin/master is at the same point as my local copy of master. Let's merge upstream/master into master and see how the log changes.

$ git merge upstream/master
Updating 97054577d..29005b829
Fast-forward
 .travis.yml                                           |   1 +
 doc/source/installing.rst                             |  11 ++++--
 yt/frontends/gadget/tests/test_outputs.py             |   6 +++
 yt/frontends/stream/io.py                             |   4 +-
 yt/visualization/plot_modifications.py                | 108 +++++++++++++++++++++++++++++++----------------------
 yt/visualization/tests/test_callbacks.py              |  13 +++++++
 yt/visualization/volume_rendering/tests/test_scene.py |   6 ++-
 7 files changed, 99 insertions(+), 50 deletions(-)
$ git log --oneline -n 15 upstream/master
29005b829 (HEAD -> master, upstream/master) Merge pull request #2133 from brittonsmith/np16
9c38681a8 Provide list type to np.column_strack to fix numpy 1.16 future warning.
b63f72f13 Merge pull request #2132 from neutrinoceros/doc_dev_conda
1b944e26b Add documentation on how to install the dev version of yt within anaconda and without using pip
2fa8519dd Merge pull request #2122 from chummels/shea_fix
6b096c0e7 Simplifying logic with np.asanyarray()
2efd85bd4 Adding test for annotation of YTArray not in code_units.
07e0b6c0f Making sanitize_coords handle both YTArrays and numpy arrays.
e1765465b Making PlotCallback methods private.
6e595e992 Merge pull request #2128 from cphyc/fix/sphere_unit_mistake
d8bc026f0 Convert radius in right unit
dfa4a9e18 Merge pull request #2125 from ngoldbaum/debian-fix
6649bc658 run tests in temporary directory. fixes #2123
97054577d (origin/master, origin/HEAD) Merge pull request #2124 from zingale/master
4efd4b2ea update the docs to reflect the fact that rays are not ordered.

now we can see that my local copy of master is pointed to the same place as upstream/master. We can update my fork with git push:

$ git push origin master
Counting objects: 92, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (46/46), done.
Writing objects: 100% (92/92), 12.84 KiB | 4.28 MiB/s, done.
Total 92 (delta 72), reused 61 (delta 46)
remote: Resolving deltas: 100% (72/72), completed with 20 local objects.
To https://github.com/munkm/yt.git
   97054577d..29005b829  master -> master
$ git log --oneline -n 3 upstream/master
29005b829 (HEAD -> master, upstream/master, origin/master, origin/HEAD) Merge pull request #2133 from brittonsmith/np16
9c38681a8 Provide list type to np.column_strack to fix numpy 1.16 future warning.
b63f72f13 Merge pull request #2132 from neutrinoceros/doc_dev_conda

Now our local copy, our fork, and our project's repository all have master pointed to the same commit.

aside: this is why branching is powerful. If we're working in a branch that's constantly being updated with remote changes, we'll have to fetch and merge and potentially perform a lot of conflict resolutions. We don't have to do that if we're working in a thematic branch.

A fork is a copy of a repository associated with your user account (or another organization). Earlier in the lesson we were pushing changes up to our individual github accounts. However, you don't always have git commit rights to different repositories. We don't want random people going and changing our research code or our research papers! Forks help us by allowing people to copy our code and make changes separately, and we can integrate those changes in our own time.

Earlier we talked about git fetch and get merge. These two commands together are git pull. A pull request is a request from a user for the a collaborator or organization to pull (or fetch and merge) their changes into their own repository. This is the way that we incorporate our work into another repository without commit rights. Pull requests can also be submitted on a single repository between two branches.

Github also has features that allow us to easily compare changes. We can do this on the command line the same way we diff two branches:

Or we can use the github GUI.

tips:

  • always pull down fresh changes from master before you branch.
  • branching is powerful because you