-
Notifications
You must be signed in to change notification settings - Fork 9
Using GitHub
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
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.
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
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'
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:
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:
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.
-
ohicore milestones on HuBoard - excellent overview
-
maintain ordering by editing
order
in top comment of issue:<!--- @huboard:{"order":0.01,"custom_state":""} -->
-
GitHub Issues 2.0: The Next Generation - lots of useful tips, including keyboard shortcuts
-
GitHub Mention @somebody. They're notified.
including
@user
in issue comments notifies that person and subscribes to future updates. -
Trying to enable creation of issues via email alone:
- Connect GitHub to Email via IFTTT doesn't seem to work based on my recipe: Send [email protected] an email tagged #ohicoreIssue from [email protected].
-
Closing Issues Across Repositories
Now you can include "fixes user/repo#45" in your commit message, and it will close the referenced issue, provided you have the permission to push to that repository.
-
curl -i -u bbest https://api.github.com/issues
-
github-issues-import - this Python script allows you to import issues and pull requests from one repository to another
-
tutorial: Team Collaboration With GitHub
- A review paper describing how git can be used to improve reproducibility in science
- Productivity in RStudio [bbest]: data wrangling with dplyr, versioning with github, documenting with markdown (note: presentation itself done in RStudio with markdown in presentation mode)