A git repo is created in the working directoryh and filled with two files:
$ git init $ echo contents of master1.lis > master1.lis $ git add master1.lis $ git commit -m"commit master1.lis" $ git branch * master $ echo contents of master2.lis > master2.lis $ git add master2.lis $ git commit -m"commit also master2.lis" $ git log --oneline --decorate d754ed1 (HEAD, master) commit also master2.lis 568d07b commit master1.lis
A second branch named test is created and filled with a file:
$ git branch test $ git checkout test Switched to branch 'test' $ git branch master * test $ echo contents of test1.lis > test1.lis $ git add test1.lis $ git commit -m"commit test1.lis" $ git log --oneline --decorate f2e002a (HEAD, test) commit test1.lis d754ed1 (master) commit also master2.lis 568d07b commit master1.lis
Switching between the branches changes the files in the working tree:
$ git branch master * test $ ls master1.lis master2.lis test1.lis $ git checkout master Switched to branch 'master' $ ls master1.lis master2.lis
An additional file is created in the master branch:
$ echo contents of master3.lis > master3.lis $ git add master3.lis $ git commit -m"commit also master3.lis, after creating test branch"
An additional file is created in the test branch:
$ git checkout test Switched to branch 'test' $ echo contents of test2.lis > test2.lis $ git add test2.lis $ git commit -m"commit test2.lis"
Here is an overview:
$ git log --oneline --decorate --all --graph * cc66a7e (HEAD, test) commit test2.lis * f2e002a commit test1.lis | * bba0677 (master) commit master3.lis, after creating test branch |/ * d754ed1 commit also master2.lis * 568d07b commit master1.lis
Notice that the tool gitg may be very helpfull to visualize the repo.