Changes between Version 73 and Version 74 of WorkingWithGit


Ignore:
Timestamp:
Jan 30, 2017, 10:02:00 PM (8 years ago)
Author:
ctreleaven (Craig Treleaven)
Comment:

Preliminary notes about using branches

Legend:

Unmodified
Added
Removed
Modified
  • WorkingWithGit

    v73 v74  
    139139
    140140
     141=== Using a branch for development === #branch
     142
     143Commonly, you'd use a local branch for development if you want this work isolated, such as when you are making experimental changes or it may take some time complete the work.
     144
     145The life cycle for a branch, say "foobar", might look like this:
     146{{{
     147git branch foobar     # creates a local branch
     148git checkout foobar
     149}}}
     150
     151- lots of edits and testing
     152
     153{{{
     154git commit -m "blah blah"
     155}}}
     156
     157
     158- more testing and corrections
     159
     160{{{
     161git commit -a --amend -m "revised blah blah"
     162}}}
     163
     164
     165- throughout the process, you can 'git checkout master' / 'git checkout foobar' to switch in and out of the branch.
     166
     167- if there are upstream changes that need to be reflected in your branch...
     168
     169{{{
     170git branch --set-upstream-to=origin/master foobar
     171git pull --rebase
     172}}}
     173
     174
     175- finally, work is done.  Now merge the changes into your local master...
     176
     177{{{
     178git checkout master
     179git merge --ff-only foobar
     180}}}
     181
     182- check that only your expected commits are about to be pushed
     183
     184{{{
     185git log origin/master..foobar
     186}}}
     187
     188
     189- normal steps to push
     190
     191{{{
     192git pull --rebase  && git push origin master
     193}}}
     194
     195
     196- if we're done with the branch, nuke it
     197
     198{{{
     199git branch -d foobar
     200}}}
    141201
    142202