GitHub Branch, Commit and Merge Steps

GitHub Branch, Commit and Merge Steps 1. Username and Email Configuration Process We need to set up a user name and email after cloning the ...

GitHub Branch, Commit and Merge Steps



1. Username and Email Configuration Process

We need to set up a user name and email after cloning the repository in 2 ways.

  1. Configuring Global Level

When you require every repository to follow the same username and email, only set up configuration with –global attribute. You also can set your organization user and email.

  • Command: 

    1. git config –global user.name “USER NAME”

    2. git config –global user.email “EMAIL”

  • Example: 

    1. git config –global user.name “Bhavin Patel”

    2. git config –global user.email “test@xyz.com

  1. Configuring Repository Level

If you do not want to use common users for every repository of your system then every time after clone you need to configure at the repository level, here you don’t need to use –global attribute.

  • Command

    1. git config user.name “USER NAME”

    2. git config user.email “EMAIL”

  • Example: 

    1. git config user.name “Bhavin Patel”

    2. git config user.email “test@xyz.com

2. Update Remote to Manage Branches with Remote

There is the possibility that on the same repository with the same branch, there are many developers are activated, so here we need to update our logs with every remote repository logs, we generally have one report that is original but there could be more than one remote, so here we need to update with every remote. To update the remote please execute the below command.


git remote update

3. Branch Create/Update Process

Whenever create any branch, we suppose to mention the source branch in the new branch, by doing this we can know the parent branch. It depends on the task or issue, it would be better to create a new one from the production branch and update that branch every time before release and merge, but it depends on a feature branch.


Do not do ”git pull” if you have any changes on your local system.


  1. Steps to create a branch if you have no changes on the local source branch.

    1. git remote update

    2. git checkout SOURCE_BRANCH

    3. git checkout -b dev_SOURCE-BRANCH_TASK-NUMBER_FEATURE

  2. Steps to update a branch before releasing any code if you have no changes on the local source branch.

    1. git remote update

    2. git rebase REMOTE_NAME/SOURCE_BRANCH

  3. Steps to create a branch if you have any changes on the source branch.

    1. git remote update

    2. git checkout SOURCE_BRANCH

    3. git rebase REMOTE_NAME/SOURCE_BRANCH

    4. git checkout -b dev_SOURCE-BRANCH_TASK-NUMBER_FEATURE

  4. Steps to update the branch before releasing any code if you have any changes on the local source branch.

    1. git remote update

    2. git rebase SOURCE_BRANCH

    3. git rebase REMOTE_NAME/SOURCE_BRANCH

  5. Steps to update the branch before releasing any code if any of your colleagues have made any changes on the same development branch.

    1. git remote update

    2. git rebase REMOTE_NAME/dev_SOURCE-BRANCH_TASK-NUMBER_FEATURE

    3. Follow Step 4.b(Only if you have changes in local system) and 4.c

    4. After above If you push the code you can have the warning to pull or rebase, but here, after rebase you need to push the code forcefully, like:

git push -f REMOTE_NAME BRANCH_NAME 

4. Commit Steps to Manage Customer Repository Only Process

For new git users, they should confirm the currently configured user name and email before committing any code on the branch, the reason is that they might not be aware of their configuration.

You can know by executing the below commands:


git config user.name

git config user.email

git config list (To know all the custom configurations)


After checking the code review your file and code executing the below commands:


git status

git status *.xml (To know the specific type of files)

git diff

git diff *.xml (To check changes of a specific type of files)

git add ADD_YOUR_REQUIRED_FILES

git commit -a <HIT ENTER HERE>


Here one terminal will be opened after hitting enter,  you can describe your changes and also can describe errors and solutions as per the feature, there are basically three parts

  • Subject

  • Body

  • Closure Status


Subject Format:

[TAG] #TASK_NUM | MODULE_NAMES: FEATURE/CHANGES TITLE AS PER TASK

Body Format:

Descript your feature or bug fixing.

Closure Status:

Mention which one Issue/task have you fixed by giving id, for example

Closed Task #735, Vertical Consultor 


After setup the commit message hit CTRL + o and then close the terminal by hitting CTRL + x, you need to update your current branch with the parent branch, to do this please follow branch creation/updation STEP#3.4 and STEP#3.5.

5. Steps to Merge branches Process

There are changes that we can have multiple staging branches and only one production branch, so here we have to check that before merging the development branch to any staging, the development branch must be updated with the production branch, there could be chances that production branch has some new updates, our releasing code could affect there so that is why we need to manage such code conflict before release our code on to the staging or production branch.


At the time of merging the development branch to staging/production when we just need to merge only no code has been done recently then we need to follow the below commands:


git remote update

git checkout dev_SOURCE-BRANCH_TASK-NUMBER_FEATURE

git rebase REMOTE_NAME/PRODUCTION_BRANCH

git checkout <STAGING or PRODUCTION>

git merge dev_SOURCE-BRANCH_TASK-NUMBER_FEATURE

git push REMOTE_NAME STAGING_OR_PRODUCTION_BRANCH_NAME


6. Steps to Resolve Conflict while Rebase/Merge Process

When you face conflict while applying to rebase, just resolve the conflict and add those files, do not commit here, use –the continue attribute of rebase, see the command below:


git add FILE_NAME1[, FILE_NAME2, .. FILE_NAME N]

git rebase –continue (for rebase)

git merge –continue (for merge)



If anyone has any concerns you can contact Bhavin Patel (Skype ID: odooindia).


0 comments