-
Talinn, Estonia
-
-
support@lnsolutions.ee
Read more on Medium
Git is a powerful version control system widely used by developers to manage source code repositories. One of the key features of Git is its support for branching, allowing developers to work on new features or experiments without affecting the main codebase. However, managing branches and resolving merge conflicts effectively are crucial skills for successful collaboration and code management. In this article, we’ll explore common Git branching tasks and how to handle merge conflicts gracefully for feature branches.
Git branches are independent lines of development within a Git repository. They allow developers to work on different features, bug fixes, or experiments without affecting the main codebase. Here are some essential concepts related to Git branches:
git checkout -b <branch-name> command. This creates a new branch and switches to it in one step.git checkout <branch-name> command. This allows you to work on different features or bug fixes seamlessly.git branch command. The branch you are currently on will be highlighted.git branch -d <branch-name> command. Be cautious when deleting branches, especially if they contain unmerged changes.Merge conflicts occur when Git cannot automatically merge changes from different branches due to conflicting changes in the same part of a file. Here’s how to handle merge conflicts effectively:
git pull origin <branch-name>.git merge <branch-name> command. Git will attempt to automatically merge the changes. If there are conflicts, Git will pause the merge process.<<<<<<<, =======, >>>>>>>) and keep the changes you want to retain.git add . and commit the merge using git commit. Git will create a merge commit to finalize the merge process.
In this example we start with main and then create a new local branch and switch to it
Read more on Medium