Version Control
A system for maintaining current and
past copies of all of your files and a record of all the changes you
have made;git
Version control software for tracking your project
on your local computerGitHub
A free, public remote website where your project
is permanently hostedRepository
Any collection of files that belong to the
same project, plus a few special git
files that set up the
version control. Also called a repo
by hipster
programmers.Clone
Create a local copy of a repository from the
GitHub website to your own website. You can clone from your own
repository or anyone else’s that is posted on GitHub. Once the files are
on your local computer you can edit or use them as you like. However,
you can only change files on GitHub for the repositories that you
yourself created or for projects that you have been invited to
collaborate on with others.Commit (the noun)
A snapshot of your file system at a
particular time. Since your last commit, it keeps track of the files you
currently have, the ones you have deleted or added, and any changes you
have made to files.Commit (the verb)
When you commit, you are taking a
snapshot of your files at the current time. You must add a summary of
the commit that briefly describes what changes you have made (such as
“add new homework file”). Note that all commits affect only the local
copy of your repository. They do not affect the remote copy that is
stored on GitHubPush
Pushing a set of changes means copying them from
your local repository up to GitHub.Pull(=fetch)
Pulling means copying the repository in
its current state on GitHub down to your local repository. This would
incorporate any changes that others have made (and pushed) in a
collaborative project.Close Project
getwd()
Session
menu set the working directory (choose
directory) to where you want the new repository to be createdgetwd()
a second time
(to confirm new location)library(devtools)
create_project("ProjectName")
This command creates the project and opens a new RStudio
environmentlibrary(devtools)
Remember the devtools
package is not open in your new
projectuse_git()
library(devtools)
use_github()
R
folder.gitignore
filegitignore
file: *.Rproj
gitignore
file: *.pdf
for other file types or individual files to ignoregit status
git add -A
git status
R Markdown...
Console
to Terminal
panelgit status
git add -A
git status
git commit -am 'add webpage'
git status
git push
These instructions are modified from Scott Hanselman’s blog
from the github General page, find the box to change “master” to “main”
Now go to each of your local clones of this repository and run
the following from the terminal prompt ($
is the prompt
before the command)
$ git checkout master
$ git branch -m master main
$ git fetch
$ git branch --unset-upstream
$ git branch -u origin/main
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
# git config --global init.defaultBranch main
These commands need to be issued only once for each local copy of the repository. These commands do the following:
1. Go to the master branch
2. Rename master to main locally
3. Get the latest commits from the server
4. Remove the link to origin/master
5. Add a link to origin/main
6. Update the default branch to be origin/main
7. Change git configuration to recognize main (may only need to be done once)
git status
(make sure your local repo is not ahead of
the remote)git pull
(just in case there was a change made from
another location)git status
(ready to start working)git status
git add -A
git status
git commit -am 'write a brief informative commit message'
(no caps or punctuation, present tense)git status
git push
git status
git pull
status
of the local repo (uncommitted changes?
local commits ahead of remote?)pull
any changes from the repo (incorporating changes
pushed by others)add
changes (local)commit
changes (local)push
changes (from local repo to GitHub)