Let's say you have a Git repo called foo.git, and the repo contains a single branch, the master branch. And within the master branch is a file named foo.txt which contains "Hello World".
You can create a branch. The branch will be an identical copy of the files in the master branch. In this example, a branch named develop is created.
git branch develop
The -a or -all flag can be used to display all of the branches in the repository.
git branch --all
Which will return something like this. The * (wildcard) character means you are currently in the master branch.
develop * master remotes/origin/HEAD -> origin/master remotes/origin/master
The git checkout command can be used to switch to the newly created branch.
git checkout develop
Which should return something like this.
Switched to a new branch 'develop'
Let's make a change to the foo.txt file, and then commit the change. Now foo.txt in the master branch contains "Hello World" and foo.txt in the develop branch contains "Goodbye World".
echo "Goodbye World" > foo.txt git commit -m "Goodbye World" foo.txt
Switch to the master branch, and then the git merge command can be used to merge the develop branch to the master branch.
git checkout master git merge develop
Something like this should be displayed, and now foo.txt in the master branch should contain "Goodbye World".
Updating ead546c..4a26c57 Fast-forward foo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)