There are different ways of doing this. You may find some don't work - in which case try the others!
- When making your R package make sure the "Create a Git Repository" tab is checked.
- When your package is open in RStudio, you should see the "Git" tab in the top right.
- Use the Git tab to add and commit your package files.
- Create a new repository on GitHub with same name. Importantly - do not add a README or anything just yet - the repo needs to be empty at this point.
- Open the command line (e.g. git bash) You can do this by opening it from your start menu, or in RStudio click Tools->Shell to open a terminal/command prompt that is automatically in the directory of the R package
- Connect the package with the GitHub repository type: "git remote add origin https://github.com/yourusername/PackageName.git"
- Then type "git push -u origin master" to push everything
- You can push/pull future changes using the Git tab in RStudio.
OR you can do it in the following sequence:
- When making your R package make sure the "Create a Git Repository" tab is checked.
- When your package is open in RStudio, you should see the "Git" tab in the top right.
- Open the command line (e.g. git bash) You can do this by opening it from your start menu, or in RStudio click Tools->Shell to open a terminal/command prompt that is automatically in the directory of the R package
- Go to the package directory (use cd ...)
- Initialize the repository - type "git init"
- Add and commit everything - type "git add -A" and then "git commit"
- Create a new repository on GitHub with same name. Importantly - do not add a README or anything just yet - the repo needs to be empty at this point.
- Connect the package with the GitHub repository type: "git remote add origin https://github.com/yourusername/PackageName.git"
- Then type "git push -u origin master" to push everything
- Repeat the git add, git commit, git push each time you want to add things (you don't have to do the origin master bit each time).
- Create repository on GitHub
- Copy over all your project files to GitHub using the "upload files" tab
- Note - if you have very large files this many not work.
- I don't recommend this - but it can work.
Make sure you have an empty repository on GitHub that is of the same name as your package.
- Open the shell from RStudio/tools.
- to set up git, type the following in order...
git init git add -A git commit
[now you have to try and write a commit message. After you manage to do that, press...]
do this by typing the following:
I
Enter
now type
Esc :wq Enter (this is to quit the commit message).
Now type:
git remote add origin https://github.com/yourusername/PackageName.git
git push -u origin master
- Now check online to see if your package is there in your repository.
If you make changes to your project and wish to add them........
- Open the shell using RStudio/tools
type:
git add -A
git commit [then add a message and quit the viewer using Esc :wq Enter]
git push
Check online - the changes should be there.