Howto:Start using git: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 19: Line 19:




Because creating a new branch and checking it directly afterwards out, is such a common operation there is a short cut available: git checkout -b my-branch
Because creating a new branch and checking it directly afterwards out, is such a common operation there is a short cut available: '''git checkout -b my-branch'''




To update the base package use "git pull" (issued in $FG_ROOT) on the UNMODIFIED master branch (which is the default).
To update the base package use '''git pull''' (issued in $FG_ROOT) on the UNMODIFIED master branch (which is the default).


This will then keep the "master" branch updated.
This will then keep the "master" branch updated.
To get a list of local branches use "git branch". This will also tell you what branch you are currently on.
To get a list of local branches use '''git branch'''. This will also tell you what branch you are currently on.


However, assuming that you modify your base package for your own work, it will indeed be better to do this in another branch (i.e. a topic branch), otherwise your own modifications may conflict with the checkout from the server, once you do a git pull so that you will have to manually merge everything. Make sure to use use "git status" and/or "git diff" on the master branch to see if you have already done any modifications that may complicate the update.
However, assuming that you modify your base package for your own work, it will indeed be better to do this in another branch (i.e. a topic branch), otherwise your own modifications may conflict with the checkout from the server, once you do a git pull so that you will have to manually merge everything. Make sure to use use '''git status''' and/or '''git diff''' on the master branch to see if you have already done any modifications that may complicate the update.


The easiest thing to do would indeed be to locally create a branch of $FG_ROOT, where you save all your work, this can be done using "git branch BRANCHNAME", where BRANCHNAME could for example be "local-weather". So just enter the base package folder and type "git branch local-weather", you should really be doing this only with a clean/unmodified master branch.
The easiest thing to do would indeed be to locally create a branch of $FG_ROOT, where you save all your work, this can be done using '''git branch BRANCHNAME''', where BRANCHNAME could for example be "local-weather". So just enter the base package folder and type '''git branch local-weather''', you should really be doing this only with a clean/unmodified master branch.


Once you issue then another "git branch", you'll see your newly created "local-weather" branch in the list of local branches.
Once you issue then another '''git branch''', you'll see your newly created "local-weather" branch in the list of local branches.


To switch to this new branch use "git checkout local-weather", that may take a second or two given the sheer size of the base package. Then you have a 1:1 copy of the last version of the master branch for doing your own local work. This is why I suggested not to create a branch from a modified master, because it will be more complicated to update it automatically.
To switch to this new branch use '''git checkout local-weather''', that may take a second or two given the sheer size of the base package. Then you have a 1:1 copy of the last version of the master branch for doing your own local work. This is why I suggested not to create a branch from a modified master, because it will be more complicated to update it automatically.


Basically: always leave the master branch alone, and only do work on topic branches, so that you can easily update the master branch.
Basically: always leave the master branch alone, and only do work on topic branches, so that you can easily update the master branch.

Navigation menu