Git: How to create a new branch from an earlier/older commit in master branch? -


i made 3 commits in master branch: c1, c2 , c3. point made new branch 'branch1'. did changes , have them commited in c4 on branch1.

things follows:

c1--c2--c3<--master          \                c4<--branch1     

however, want use earlier commit in master fork off new branch 'branch2'. i.e. in master branch, want go in time @ c2 , build on top of in new branch. master branch not disturbed in way. c5 commit saving changes done in new 'branch2'. graphically, following figure should explain want:

      c5<--branch2      / c1--c2--c3<--master          \                c4<--branch1     
  1. what git command sequence(s) take me there?

  2. my second question after achieving case in second figure, if 'revert' performed remove c3 in master branch, effect have on branch1? code in branch1 become corrupted or unstable?

simply check out commit , specify branch create:

git checkout -b branch2 c2 

for second question, depends on how define 'revert' (git revert or git reset). in both cases branch1 still contain commit c3 (remember, in git branches 'pointers', ancestry information stored in commits themselves).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -