We’ve already gone over markdown and RStudio in class. You can download RStudio at RStudio homepage. You can learn more about markdown at Markdown Help via RStudio.
Git is used for version control. Bitbucket is a free, private repository for using version control and sharing code, files, etc. (Github does the same thing). You can download bitbucket at Bitbucket homepage.
create a new directory, open it and perform
git init
to create a new repo.
create a working copy of a local repository by running the command
git clone /path/to/repository
when using a remote server, your command will be
git clone username@host:/path/to/repository
You can propose changes (add it to the Index) using
git add <fileName>
This is the first step of the basic git workflow. To commit these changes (to the master directory) use
git commit -m "Commit <add helpful message>.
Now the file is committed to the HEAD but not in your remote repository yet.
Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute
git push origin master
Note: Change master to whatever branch you want to push your changes to. Now you are able to push your changes to the selected remote server (bitbucket for example.)
Branches are used to develop features isolated from each other. The master branch is the “default” branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion.
Create a new branch named “feature_x” and switch to it using
git checkout -b feature_x
Switch back to the master branch
git checkout master
and delete the branch again
git branch -d feature_x
A branch is not available to others unless you push the branch to your remote repository
git push origin <branch>
To update your local repo to the newest commit, do
git pull
in your working directory to fetch and merge remote changes.
To merge another branch into your active branch (e.g. master), use
git merge <branch>
in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in conflicts. You are responsible to merge those conflicts manually by editing the files shown by git. After changing, you need to mark them as merged with
git add
before merging changes, you can also preview them by using
git diff <source_branch> <target_branch>
Note that in order to often fix conflicts, you will need to do this using vim. To enter the vi environment, type vi Then follow the instructions to address why you are making a merge. To save and exit, press esc followed by :wq enter which will save the changes and take you back to the console. (This is possibly the most annoying and tedious process but once you have it down, it’s easy.)