I’ve had to change my R package names a few times.
Every time I’ve had to do this, there were a few things I had to remember to do. Here’s a blog post that describes how to do that.
There are two parts, changing the R package name, and changing the git/github settings.
Part 1: Changing the R package name
When you change your package name, here is a list of things you need to do.
- update your DESCRIPTION file package name
- update the NEWS.md
- update the name in the README file
- update the .RProj name
- update the folder name
- update your package-
.R file - Do a search (Cmd/Ctr + Shift + F) and look for mentions of your package name
And that’s basically it!
Hooray, now to handle the git business.
Part 2: Changing the github name
Now, with this final setup, what you want to do is go into your github repo, go to settings, then change the repo name.
You will then need to tell git where to look for your package online, as the URL has changed.
First, let’s show where the origin is.
git remote show origin
* remote origin
Fetch URL: https://github.com/<USERNAME/ORGANISATION>/<REPO-NAME>.git
Push URL: https://github.com/<USERNAME/ORGANISATION>/<REPO-NAME>.git
HEAD branch: master
Remote branches:
maddiedoc tracked
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
Then, remove the origin, with
git remote rm origin
Nothing will happen. That is good. Now, check that you have no origin file.
git remote show origin
git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Great. Now, add the new origin.
git remote add origin https://github.com/<USERNAME/ORGANISATION>/<YOUR-NEW-REPO-NAME>.git
Nothing will happen. This is good.
Now, check that the remote has been set.
git remote show origin
remote origin
Fetch URL: https://github.com/<USERNAME/ORGANISATION>/<YOUR-NEW-REPO-NAME>.git
Push URL: https://github.com/<USERNAME/ORGANISATION>/<YOUR-NEW-REPO-NAME>.git
HEAD branch: master
Remote branches:
maddiedoc new (next fetch will store in remotes/origin)
master new (next fetch will store in remotes/origin)
Local ref configured for 'git push':
master pushes to master (up to date)
Great, now make your changes, then add them, then do a commit.
git add .
git commit -m "updated package doco to be clearer about what the data is"
And then push them.
git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
This is fine.
Before we can push these changes onto github, we need to tell it where to push to.
Do this with
git push -u https://github.com/<USERNAME/ORGANISATION>/<YOUR-NEW-REPO-NAME>.git
This tells git where you want to push to, and to keep pushing there.
And that’s it!
Happy coding