Once you can commit and push with Git, the next skill every developer and DevOps engineer needs is branching. Branches let you build a feature or fix a bug in isolation, then merge it back when it works.
Creating and switching branches
git switch -c feature/login-page creates a new branch and moves to it. git switch main goes back. git branch lists your branches, with an asterisk on the current one. Name branches after their purpose, such as feature/, fix/ or docs/.
Merging
When the feature is ready, switch to main and run git merge feature/login-page. If main has not changed since you branched, Git simply moves main forward (a fast-forward merge). If both branches have new commits, Git creates a merge commit that joins them.
Merge conflicts
A conflict happens when both branches changed the same lines. Git marks the file with <<<<<<<, ======= and >>>>>>> sections. To resolve it:
- Open the file and decide what the final code should be.
- Delete the conflict markers.
- Run
git addon the file and thengit commit.
Conflicts are normal; small, frequent merges keep them small.
A simple team workflow
- Pull the latest main.
- Create a feature branch.
- Commit small, clear changes.
- Push the branch and open a pull request.
- A teammate reviews it; automated tests run in the CI pipeline.
- Merge into main and delete the branch.
Merge vs rebase
git rebase main replays your commits on top of the latest main, giving a straight history. It is useful on your own branches, but never rebase commits that teammates have already pulled.
Related: Git and GitHub for beginners and CI/CD explained.
Git, Linux and CI/CD are practised in our AWS and DevOps course in Bangalore.
Book a free demo class at our BTM Layout centre, and ask a counsellor for batch details.
