add git-note file
[blog.git] / git-note.org
1 #+TITLE: Git Note
2 #+AUTHOR: Peng Li
3 #+EMAIL: seudut@gmail.com
4 #+DATE: 2016-12-18
5
6 * Git Note
7 ** Update an forked repo on  Github
8 See [[http://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository]]
9 #+BEGIN_SRC sh :results output replace
10   # Add the remote, called it "upstream", which is the original repo forked
11
12   git remote add upstream https://github.com/whoever/whatever.git
13
14   # Fetch upstream
15
16   git fetch upstream
17
18   # switch to master
19
20   git checkout master
21
22   # rebase all commit in upstream
23
24   git rebase upstream/master
25
26   # push the new commit
27
28   git push origin master
29 #+END_SRC
30
31 ** Move branch pointer to commit
32 Ususally, we create a branch for some bug fix. If it is a regress issue, we oftern need to rollback to some commit to fix the 
33 bad commit. In this case, we need to move the branch to another commit
34 [[http://stackoverflow.com/questions/5471174/git-move-branch-pointer-to-different-commit-without-checkout]]
35
36 #+BEGIN_SRC sh :results output replace
37   git branch -f branch-name COMMIT
38 #+END_SRC
39