Skip to content
Ben Best edited this page Aug 16, 2014 · 33 revisions

Process

github.com/[org]/[repo] (org web) github.com/[user]/[repo] (user web) ~/github/[repo] (user local)
->1x -> fork -> clone
<- merge pull request {admin} <- <- [pull request](Fork & Pull Model) <- push, <-> commit

where:

  • [org] is an organization (eg ohi-science)
  • [repo] is a repository in the orgranization (eg ohicore, ohiprep, etc.)
  • [user] is your github username

Other workflows

Resolving Conflicts

See:

In this example, pull request ohi-science/ohicore#94 for bbest/ohicore to update ohi-science/ohicore returns the message:

We can’t automatically merge this pull request. Use the command line to resolve conflicts before continuing.

Checkout via command line

If you cannot merge a pull request automatically here, you have the option of checking it out via command line to resolve conflicts and perform a manual merge.

HTTP: https://github.com/bbest/ohicore.git

Step 1: From your project repository, check out a new branch and test the changes.

git checkout -b bbest-master master
git pull https://github.com/bbest/ohicore.git master

Step 2: Merge the changes and update on GitHub.

git checkout master
git merge --no-ff bbest-master
git push origin master

Here are the extra steps to resolve this conflict. First, you need a local copy of ohi-science/ohicore in a temporary directory.

cd ~/github
mkdir tmp; cd tmp
git clone https://github.com/ohi-science/ohiprep.git
cd ohiprep

Then checkout a new branch bbest-master based on master, and overwrite with the bbest repo.

git checkout -b bbest-master master
git pull https://github.com/bbest/ohiprep.git master

The Auto-merging will then detect CONFLICTs. In this case:

CONFLICT (content): Merge conflict in Global/WorldBank-Statistics_v2012/data_prep.R

Try using the DiffMerge (see integration with git)

git mergetool

This should launch an application to choose which blocks of text, left (ohi-science) or right (bbest), to apply using the toolbar buttons. Select blocks and click Save.

git_mergetool_screen.png

To look at the various versions of the file separately:

# local
open Global/WorldBank-Statistics_v2012/data_prep.R

# ohi-science web
open https://github.com/ohi-science/ohicore/blob/master/Global/WorldBank-Statistics_v2012/data_prep.R

# bbest web
open https://github.com/bbest/ohicore/blob/master/Global/WorldBank-Statistics_v2012/data_prep.R

Let's overwrite with the raw online version of the file from the bbest repo.

curl -L -o Global/WorldBank-Statistics_v2012/data_prep.R "https://raw.github.com/bbest/ohiprep/master/Global/WorldBank-Statistics_v2012/data_prep.R"

Once the conflicts are resolved, mark the resolved file(s) with git add and then commit with a message.

git add Global/WorldBank-Statistics_v2012/data_prep.R
git commit -m "resolved conflict with Global/WorldBank-Statistics_v2012/data_prep.R by overwriting with bbest version"
git status

Finally, merge the branches and push back to github.

git checkout master
git merge --no-ff bbest-master -m "merging to resolve conflict Global/WorldBank-Statistics_v2012/data_prep.R"
git push origin master

Now you can delete this temporary branch

cd ~/github
rm -rf tmp

Fixing RStudio Push/Pull Errors

on Push, "remote: error: GH001: Large files detected"

remote: warning: File Global/NCEAS-Fisheries_v2014/raw/DataCheck/CatchStatusCMSYFinal.csv is 92.09 MB; this is larger than GitHub's recommended maximum file size of 50 MB        
remote: error: GH001: Large files detected.        
remote: error: Trace: 5f775f8044e2e8ddb0f0251540662c6e        
remote: error: See http://git.io/iEPt8g for more information.        
remote: error: File Global/NCEAS-Fisheries_v2014/raw/Extension_redo_withFlag.csv is 120.00 MB; this exceeds GitHub's file size limit of 100 MB        
To https://github.com/katlongo/ohiprep
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/katlongo/ohiprep'

on Push, error: unable to read askpass response from 'rpostback-askpass'

If you're using the latest version of RStudio (eg version 0.98.501) on Mac or Linux, you're probably getting this error when pushing commits within RStudio to github:

error: unable to read askpass response from 'rpostback-askpass'
fatal: could not read Username for 'https://github.com': Device not configured

In the GUI, this looks like this:

image

There's a problem with the latest https authentication using RStudio. The easiest way around this for now is to sync with the online repository using the GitHub application Mac or Windows. You can work in RStudio but use the GitHub app to push/pull until the RStudio bug is fixed. See below for fix you can try in Terminal if you'd like to use RStudio to sync, but this does not always solve the problem.

This error in RStudio is not actually a problem with git or storing your username password, since the following works from Terminal:

cd ~/[github_dir]/[repo]
git push

So the solution to get RStudio to play nicely again is to switch the repository URL from https to ssh by editing the repository's config. Since it's in a hidden folder (prefixed with .) and you may want to edit from terminal after ssh [email protected], I recommend editing the file like so:

pico ~/[github_dir]/[repo]/.git/config

Then you'll want to comment out the https and use the alternative ssh address that begins with git to look like:

[remote "origin"]
        #url = https://github.com/bbest/ohiprep.git
        url = [email protected]:bbest/ohiprep.git

Note that in the above example you'll want to switch to out: bbest=[user] and ohiprep=[repo].

PS Another quick way to get the ssh URL that starts with git is to visit your repository online, click for the SSH clone URL like so:

bbest_ohiprep

on Pull, error: Permission denied (publickey)

Even after setting the url to the [email protected] SSH address mentioned above, you might also get this RStudio error message when Pulling:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

BEST FIX. You need to Generate an SSH Key on your local machine and associate it with your online Github settings.

QUICK FIX. Using the Github application (see download for your OS), and running Sync Branch got me past this error on a Mac.

Issues

Styling

Markdown

Reproducible Science