Using git with Bioconductor
Here I provide a brief description of using git to manage Bioconductor packages. A detailed description is provided here.
Create a new repository:
- I have GitHub account with username
- I have an existing Bioconductor package called
Create a new repo on GitHub with the same name as the package (
- Clone the empty repo to my local machine:
git clone https://github.com/haowulab/mypkg.git
Note after this step, the GitHub repo is the origin of my local repo.
- Add a remote to the cloned (local) repository (needs to be done in
git remote add upstream firstname.lastname@example.org:packages/mypkg.git
git.bioconductor.orgto be the upstream of my local repo.
- Fetch content from remote upstream.
git fetch upstream
- Merge upstream with origin’s master branch,
git merge upstream/master
Push changes to your origin master (this updates the content on GitHub):
git push origin master.
- Push changes to the upstream master (updates the content on Bioconductor):
git push upstream master. In order for this step to be successful, Bioconductor must grant you the access. Need to submit public SSH key here.
View existing remote
In the local git repo, do
git remote -v. I see following:
origin https://github.com/haowulab/DSS.git (fetch) origin https://github.com/haowulab/DSS.git (push) upstream email@example.com:packages/DSS.git (fetch) upstream firstname.lastname@example.org:packages/DSS.git (push)
Make and commit changes to existing
- After making changes, run
git commit -a -m "some msg"to commit all changes at once.
git addadds a new file to the repo.
git rmremoves an existing file in the repo.
- After making changes, one needs to push the changes to the upstream and origin, by doing
git push -u origin master git push -u upstream master
git push -u upstream master will fail with a warning message like
failed to push some refs to 'email@example.com:packages/DSS.git'. Updates were rejected because the remote contains work that you do not have locally.
This is usually caused by conflicts in files between local and upstream (bioconductor). Most likely, in the
DESCRIPTION file becasue bioconductor modify the version number in new release. To resolve this, first run
git pull upstream master
Then fix the file with confliction (such as
DESCRIPTION), and commit/push.