Create and merge a local git branch
This article shows how to create a local git branch to test some things and merge it back into master.
$ git status On branch master Your branch is up to date with 'origin/master'.
$ git checkout -b pyside Switched to a new branch 'pyside'
Make changes to the code.
$ git status On branch pyside Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: requirements.txt no changes added to commit (use "git add" and/or "git commit -a")
Add and commit
$ git add -A $ git commit -m "pyside added to requirements" [pyside a069fc42] pyside added to requirements 1 file changed, 2 insertions(+)
Merge to master
$ git checkout master Switched to branch 'master' Your branch is up to date with 'origin/master'.
$ git merge pyside Updating 33654d11..a069fc42 Fast-forward python/requirements.txt | 2 ++ 1 file changed, 2 insertions(+)
$ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean
Written by Loek van den Ouweland on February 22, 2021. Questions regarding this artice? You can send them to the address below.