This blog will demonstrate the procedure to merge another developer’s branch into our project.
How to Merge Another Developer’s Branch into Our Project?
To merge another developer’s branch into your project, try out the below-provided steps:
- Navigate to another developer’s repository and copy its HTTP URL.
- Switch to the local directory.
- Add another developer’s repository as a remote in your project.
- Fetch remote repository content and choose the desired remote branch.
- Merge the remote branch in your repository using the “git merge <remote-branch>” command.
Step 1: View Desired Branch Content
First, navigate to another developer’s project whose branch you want to merge into your project. For instance, we want to merge the “GitUser0422” developer’s “master” branch content into our project:
Step 2: Copy HTTPS URL
Next, copy the HTTP URL of another developer’s repository:
Step 3: Navigate to the Local Repository
Then, redirect to the particular local directory:
Step 4: Add Remote URL
Now, add the other developer’s repository as a remote in your project:
Step 5: Verify Remote URL
Ensure whether the remote has been added not through the below-provided command:
Step 6: Fetch Remote Changes
After that, run the provided command to fetch the changes of desired target branch:
It can be seen that the other developer’s branches including content have been fetched into our local repository:
Step 7: View Remote Branches
To list the remote branch, type out the following command. Here, the “-r” option is used to list only the remote branches:
It can be seen that the current repository contains “main” and “master” two remote branches:
Step 8: Merge Desired Branch
Now, execute the “git merge” command along with the desired remote branch name that needs to be merged with the current local repository. For instance, we want to merge the content of the “master” branch:
The below output indicates that the merge operation has been performed successfully:
Step 9: Verify Changes
Lastly, view the commit history to ensure that the remote branch has been merged successfully:
As you can see, the remote branch has been merged with the project:
We have explained the method of merging another developer’s branch into our project.
Conclusion
To merge another developer’s branch into your project, first, copy the HTTP URL of another developer’s repository and add it as a remote in your project. Then, fetch the remote repository’s content. Next, view remote branches and choose the desired branch that you want to merge into your project. Lastly, execute the “git merge <remote-branch>” command and verify changes. This blog has demonstrated the procedure to merge another developer’s branch into our project.