Skip to content

Version control with git (github)

variani edited this page Apr 14, 2015 · 7 revisions

References

Workflow and project organization

Git scripts and tools

Configuration of git

Git on the web

Basic 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 single repo

git clone -b gh-pages --single-branch https://github.com/variani/thesis.git thesis-gh-pages

pull issue

> $ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.gh-pages.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

Notes: https://github.com/regebro/die-git-die.

Solution: edit .gitconfig file

[push]
	default = current
[branch "gh-pages"]
  remote = origin
  merge = refs/heads/gh-pages
  rebase = true	

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