Put your stuff on GitHub
Goals
- I want everyone to walk through the process of:
- Making an RStudio project with git version control
- Committing some stuff in it.
- Making a “home” for that at GitHub
- Pushing the contents to GitHub
- Modifying something, committing, and pushing it up anew.
- Cloning the repo elsewhere.
- The folks at RStudio and GitHub have worked pretty hard to make such a process about as easy as can be.
Make a project
- By now, this should be familiar:
- From RStudio, choose File -> New Project…
- Choose “New Directory” then “Empty Project”
- Give the directory a name (like
my_proj
) 4 Click the button to use git version control
Make some changes and commit them.
- For this step, try something like this:
- Choose File -> New File -> Text File
Then insert something like:
into it and save that as a file called# My own (basically empty) project on GitHub I am just figuring out how to put my own stuff up on GitHub.
README.md
in the top level of your project directory.- Make a new file (if you want) and add some R code to it.
- Commit those new files
- Stage the files you want to commit. This should be at least
.gitignore
,my_proj.Rproj
, andREADME.md
- Commit them (write a short commit message).
- Stage the files you want to commit. This should be at least
- Cool. At this point you have a git repo you can put on GitHub.
Putting it up on GitHub
- Here is the strategy that we will follow for this part (in brief)
- Go to GitHub and create a new repository there named
my_proj
- Follow the instructions on GitHub on how to get info into that repository.
- Go to GitHub and create a new repository there named
- In more detail here it how your create a new repository on GitHub
- Go to your GitHub page. It will be at
https://github.com/USERNAME
where USERNAME is replaced with your GitHub name. - On the top right of the page there is a
+
symbol with a little triangle next to it (should be just to the right of your username). Click this and chooseNew Repository
. - In the text box, type in
my_proj
- In the Description box, feel free to put whatever you want to in there. (Like
first attempt!
) - Leave the
Public
button checked. - DO NOT initialize the repo with a README file. Neither should you click the button to add a
gitignore
or a license file. - Hit
Create Repository
- Go to your GitHub page. It will be at
- Now, here is how you get your stuff into that repo.
- After doing the above steps, you get a screen that shows a quick setup. Make sure that the
http
button is activated, instead of thessh
button. - Copy the two lines of code under where it says _or push an existing repository from the command line__
- Open up a Shell from your
my_proj
RStudio project. (Choose Tools -> Shell) and paste the two lines of code into the shell. (You probably have to hit return after that, too.) If everything worked correctly, you should see a messsage like this:
Counting objects: 5, done. Delta compression using up to 2 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (5/5), 567 bytes | 0 bytes/s, done. Total 5 (delta 0), reused 0 (delta 0) To https://github.com/eriqande/my_proj.git * [new branch] master -> master Branch master set up to track remote branch master from origin.
- That is it. Now you can commit new changes and easily push them up to GitHub from within RStudio.
Go back to your GitHub page and choose the repositories tab and you will find your
my_proj
repo there.
- After doing the above steps, you get a screen that shows a quick setup. Make sure that the
Have fun playing around
- Here are some thing to try:
- Note that you can actually edit files directly on GitHub (try to figure out how to edit your README on GitHub) and then commit those changes. Then you can pull them down to your local repo.
In the Shell, go to a new directory and then give a command like:
where USERNAME is replaced with your username. (Note that on the right side of yourgit clone https://github.com/USERNAME/my_proj.git
myproj
repository page on GitHub, you can find the correct https clone URL.- This will give you a completely new clone of your repository. This can be nice if you need to set up work on a different computer, etc.
comments powered by Disqus