Search code examples
gitgithubmergerepositorygit-remote

Branching and merging my github remote repo


I am quiet new to git and github. I have a team of 4 working on a project and have set up a remote repo in github. We have been pushing to the master branch for several weeks now. I want to know how to push to a test branch and later after reviewing merge it to the master when finalized. Can someone help?

I have tried creating a test branch and merging it with the master and it messed up the whole history. It says the master is behind the test by 'n' commits and this doesn't seem right.


Solution

    1. First, from the command line, make sure your master branch is up-to-date locally:

      git checkout master

    2. Create a new local branch named feature/test:

      git checkout -b feature/test

    3. Make changes to some files.

    4. Tell Git to track the changes you made to your files - repeat this step to add all of the changed files:

      git add (path to file that was changed)

    5. Create a commit with all your changes:

      git commit -m "a message about your commit"

    6. Push this set of changes to a feature/test branch on your team Github:

      git push origin feature/test

    7. Now, create a Pull Request via the GitHub UI: Click on the Pull Requests tab, click New pull request. Choose master as the Base branch and feature/test as the Compare branch, then click Create pull request.
    8. You'll now see a pull request created for your test branch, which your team can comment on. To make further changes based on feedback, just repeat steps 3-6 and the Pull Request will automatically be updated with your changes.
    9. When you're satisfied with the changes, click the Merge button to commit your changes to the master branch.