List all branches:

git branch -a

Create a local branch

git checkout -b dc-server-modification

switch to master after creating branch

git checkout master

switch to branch

git checkout dc-server-modification

Create a remote branch under origin/master

git branch -t dc-server-modification origin/master

Checkout locally remote branch

git checkout -b dc-server-modification

Push to remote branch

How do you merge your changes performed on the branch with the master, while you are there on the branch?
git branch -a : “check the branch on which you are on”
git checkout dc-server-bug-fixes : “checkout the branch”
//Make changes
git add -A && git commit -m “bug fixes”
git status : “check up to date”
git rebase master : Rebase on master happens
git checkout master
git merge dc-server-bug-fixes: “merges all changes master”
git push -u origin master

The following steps might help anyone who are new to git rebase and wanted to do it without hassle

Step 1: Assuming that there are no commits and changes to be made on YourBranch at this point. We are visiting YourBranch.

git checkout YourBranch
git pull –rebase
What happened? Pulls all changes made by other developers working on your branch and rebases your changes on top of it.

Step 2: Resolve any conflicts that presents.

Step 3:

git checkout master
git pull –rebase

What happened? Pulls all the latest changes from master and rebases master on latest master.

Step 4: Resolve any conflicts that presents.

Step 5:

git checkout YourBranch
git rebase master
What happened? Rebase on master happens

Step 6: Resolve any conflicts, if there are conflicts. Use git rebase –continue to continue rebase after adding the resolved conflicts. At any time you can use git rebase –abort to abort the rebase.

Step 7:

git push –force-with-lease
What happened? Pushing changes to your remote YourBranch. –force-with-lease will make sure whether there are any other incoming changes for YourBranch from other developers while you rebasing. This is super useful rather than force push. In case any incoming changes then fetch them to update your local YourBranch before pushing changes.

Why do I need to push changes? To rewrite the commit message in remote YourBranch after proper rebase or If there are any conflicts resolved? Then you need to push the changes you resolved in local repo to the remote repo of YourBranch

Yahoooo…! You are succesfully done with rebasing.

You might also be looking into doing:

git checkout master
git merge YourBranch : “merges the branch with your master”
git push -u origin master : “pushes to master”

git diff is a simple command to get to know the differences to a file over commits. While this is extremely helpful in terms of changes between commits, we could also employ this to check out changes over commits across branches.

Comparing 2 Branches in GIT

This compares the tip of branch _1 with the tip of branch_2

git diff branch_1..branch_2

That will produce the diff between the tips of the two branches. If you'd prefer to find the diff from their common ancestor to test, you can use three dots instead of two:

git diff branch_1...branch_2

To compare files within 2 different branches

git diff branch_1:df/file_1json branch_2:df/file_2.json > diff

Branch from a Branch

To checkout a branch not from the master but a specific branch

git checkout -b newBranch srcBranch

A sample Graphical Illustration Of Creating Branches Under another Branch