Git-Mrt-Map

Git for MRT map

1) Deal with Merge points(Transit Station)

   (Tamsui) touch Zhongshan
            git add Zhongshan
            git commit -am "Zhongshan"
            git checkout master
   # master branch stays at Beimen --> Songshan
   (master) git merge Zhongshan --no-ff

However, this approach will create two Songshan nodes,

One is from Tamsui branch, and the other one is from

the merge of master and Tamsui branches which stays at master branch

Figure:

   -----<Tamsui>--------Zongshan
                             \
   ---<master>----------------Zongshan--------->                      

OR


   # Tamsui stays at Taipei Main Station --> Tamsui
   (Tamsui) git log     # checkout your current station
            git checkout master

   # master stays at Beimen --> Songshan
   # I want to use <master> branch to merge(fast forward) to other branch
   (master) git merge Tamsui --no-ff
            # Add "Zhongshan" to the merge comment
   # Then, you will see one Zhongshan node only!!!

Figure:

                    (master)$ git checkout -b NewTamsui
                                    (Create new branch)     
 --<Tamsui>---TPE Station-     --<New Tamsui branch>-->
                          \   /
 --<master>----BeiMen-----Zongshan--------------> master

PS. You can use either master or Tamsui branch to merge for the transit station

This way you will leave the <Tamsui> branch points to its previous node(TPE Main Station).

But <master> branch moves forward to the new merge point (Zhongshan: Tamsui and master)

So, you have to create a new branch from that merge point to continue the task

   (master) git checkout -b NewTamsui

   if master HEAD has moved to new commit, you can use `git log` to query
   the SHA1 commit of Zongshan, then use the following command 
   to create the new branch from there.

   (master) git branch branchname <sha1-of-commit>

   Ex:
   (master) git branch NewTamsui 8608c5c   

2) Git commands Review

a. If you want to move backward


      (master) git reset --hard <commit hex value>

       Note: <commit hex value>: you can know this value from git log

b. Git rename branch

      $ git branch -m <oldname> <newname>

      If you want to rename the current branch, you can simply do:
      $ git branch -m <newname>

c. Push all branches and tags

      $ git push --all origin

d. If your local repository is older than remote, please do take this very carefully
to force the remote push with -f option

      $ git push -f origin master
    OR
      push multiple branches
      $ git push --all -f origin