A typical workflow with Git branching
A distributed version control system such as Git is designed for the complex and nonlinear workflows that are typical in interactive computing and exploratory research. A central concept is branching, which we will discuss in this recipe.
Getting ready
You need to work in a local Git repository for this recipe (see the previous recipe, Learning the basics of the distributed version control system Git).
How to do it...
- We go to the
myproject
repository and we create a new branch namednewidea
:$ pwd /home/cyrille/git/cookbook-2nd/chapter02 $ cd myproject $ git branch newidea $ git branch * master newidea
As indicated by the star
*
, we are still on the master branch. - We switch to the newly-created
newidea
branch:$ git checkout newidea Switched to branch 'newidea' $ git branch Master * newidea
- We make changes to the code, for instance, by creating a new file:
$ echo "print('new')" > newfile.py $ cat newfile.py print(&apos...