Skip to content

Version control with git (github)

variani edited this page Feb 20, 2014 · 7 revisions

References

Workflow and project organization

Git scripts and tools

Git commands

References

Configuration

git clone https://github.com/username/Hello-World.git # local repository will be named *origin*.

In clone's default setup, the default local branch tracks the origin remote, which represents the default branch in the remote repository.

update via stackoveflow.com

# svn update
git pull

An equivalent of "svn update" would be "git pull --rebase". Also please remember that you can do "git fetch" separately from the "git merge" part of "git pull".

Commit

git add README
git commit -m 'first commit'
git push origin master

Clone a github repo

# fork the repo on github.com

# clone
git clone https://github.com/variani/lme4.git

# configure the local repo to keep track on the original repo
git remote add upstream https://github.com/lme4/lme4.git
git fetch upstream
git branch -a

# change code to `upstream/flexLambda`
git checkout upstream/flexLambda

# create a local branch with the same name `origin/flexLambda`
# - this new branch will be syncronized with `upstream/flexLambda`
git checkout -b flexLambda upstream/flexLambda

# create another local branch `origin/flexLambda-dev` with a starting point `origin/flexLambda`
git checkout -b flexLambda-dev flexLambda

# add and push changes
touch R/flexLambda.R
git add R/flexLambda.R
git commit -m 'first change'
git push origin flexLambda-dev

# pull 
git pull origin flexLambda-dev
Clone this wiki locally