Made with Gila CMS

Git: Add new features with branches

Posted on December 9, 2019

 

Create a new branch and move in it

git branch {new-feature}
git checkout {new-feature}

Be sure in which branch you are any time

git branch

While you are in the new feature's branch you can make your commits, this may take some time. You may need to switch on other branches, before that you always must commit any changes. When your code is ready you do the last commit in the branch

git add -A
git commit -m "{message}"

Before git add -A you can use git diff to see the changed files.

Update master if it was changed until now

git checkout master
git pull
git checkout {new-feature}

Merge master to your branch and upload it to repository

git merge origin/master
git push

Then, on the repository's page, you can do Compare & pull request for your branch.