Git is an open source distributed version control system.
A useful minimum set of commands for Everyday Git -> https://www.kernel.org/pub/software/scm/git/docs/giteveryday.html
See my post on Git -> http://davetang.org/muse/2013/09/04/getting-started-with-git/
Set up key -> https://help.github.com/articles/generating-ssh-keys
Notes taken from http://try.github.com/levels/1/challenges/1
#to initialize a Git repository git init
#check current state git status
#start tracking changes made to octocat.txt #to add multiple files #git add one.txt two.txt git add octocat.txt
#to store our staged changes git commit -m "Add cute octocat story"
#check log git log
#push our local repo to the GitHub server git remote add origin firstname.lastname@example.org:davetang/try_git.git
#if you want to remove origin git remote rm origin
#specify where to put our commits git push -u origin master
#check for changes on our GitHub repository git pull origin master
#look at what is different from our last commit #diff between last commit and what's been staged #git diff --staged git diff HEAD
#unstage files git reset octofamily/octodog.txt
The default Git branch is master. Branches allow you to work on and switch between different versions of your project.
#to delete a branch git branch -d clean_up
#create a file called .gitignore in the root #and add stuff you don't want tracked seq_data/*.fastq
Guide to branching and merging https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
Viewing the commit history http://git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History
Checking a specific commit
git log git show <revhash>
Git difference between two commits
git log git diff 2879cb83af7fe43c741f6ff298b22d4f7f267bc8 9d9f2f406564d6ed76b0427d5223c187570c8d29
Unmodifying a Modified File (see http://git-scm.com/book/en/Git-Basics-Undoing-Things)
git checkout -- some_file.txt
Throw out all changes (http://gitready.com/beginner/2009/01/11/reverting-files.html)
git checkout -f #or git reset --HARD
Cloning with SSH
#git clone ssh://email@example.com/<user>/<repository name>.git git clone ssh://firstname.lastname@example.org/davetang/23180801.git
git clean -fd
Hard delete unpublished commits
git reset --hard 0d1d7fc32
Rebase is one of two Git utilities that specialises in integrating changes from one branch onto another. The other change integration utility is git merge. Rebasing is the process of moving or combining a sequence of commits to a new base commit. From a content perspective, rebasing is changing the base of your branch from one commit to another making it appear as if you'd created your branch from a different commit. Internally, Git accomplishes this by creating new commits and applying them to the specified base. It's very important to understand that even though the branch looks the same, it's composed of entirely new commits.
Update a fork
git clone https://github.com/davetang/scRNA-seq_notes.git cd scRNA-seq_notes/ # add remote as upstream git remote add upstream https://github.com/mdozmorov/scRNA-seq_notes.git # show remote git remote origin upstream # fetch all the branches of that remote into remote-tracking branches, # such as upstream/master: git fetch upstream # check which branch you are on git branch * master # switch to master branch if you are not on master git checkout master # rewrite your master branch so that any commits of yours that # aren't already in upstream/master are replayed on top of that # other branch: git rebase upstream/master # push to origin remote git push origin master
git add -A
Stage all tracked files
#-a stage all modified files git commit -a -m 'message'
Configure name and email
git config --global user.name "Dave Tang" git config --global user.email "email@example.com"
git config -l user.name=Dave Tang ...
Using Git with terminal colours
git config --global color.ui true
To use ssh authentication change "https://github.com/" to "firstname.lastname@example.org:", for example:
git clone https://github.com/davetang/repo.git git clone email@example.com:davetang/repo.git
GitHub Standard Fork & Pull Request Workflow -> https://gist.github.com/Chaser324/ce0505fbed06b947d962
git clone https://github.com/davetang/davetang.github.io #or using ssh key #git clone firstname.lastname@example.org:davetang/davetang.github.io cd davetang.github.io echo "Hello World" > index.html git add --all git commit -m "Initial commit" git push
Then visit: http://davetang.github.io
Documentation here -> https://help.github.com/categories/20/articles
Using Jekyll with Pages -> https://help.github.com/articles/using-jekyll-with-pages
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz tar -xzf ruby-2.1.1.tar.gz cd ruby-2.1.1/ ./configure make sudo make install
sudo gem install bundler
Installing GitHub Pages Ruby Gem
sudo gem install github-pages
Create Gemfile (placed in the root directory of your repository), which contains:
source 'https://rubygems.org' gem 'github-pages'