What is git rebase?

What is git rebase?

In Git, there are two main ways to integrate changes from one branch into another: the merge and the rebase. In this section you’ll learn what rebasing is, how to do it, why it’s a pretty amazing tool, and in what cases you won’t want to use it.
Rebasing is the process of moving or combining a sequence of commits to a new base commit. Rebasing is most useful and easily visualized in the context of a feature branching workflow. The general process can be visualized as the following:
From a content perspective, rebasing is changing the base of your branch from one commit to another making it appear as if you'd created your branch from a different commit. Internally, Git accomplishes this by creating new commits and applying them to the specified base. It's very important to understand that even though the branch looks the same, it's composed of entirely new commits.

If you go back to an earlier example from Basic Merging, you can see that you diverged your work and made commits on two different branches.
The easiest way to integrate the branches, as we’ve already covered, is the merge command. It performs a three-way merge between the two latest branch snapshots.There while merege new extra commit is generated which wont gives us the commit history linearity but in rebase we will have commit history linearity.

Note : Git Rebase is used for git commit history linearity.

Content in master branch:

Content in development branch:

Content After rebase:

Pulling via Rebase

he --rebase option can be used to ensure a linear history by preventing unnecessary merge commits. Many developers prefer rebasing over merging, since it’s like saying, "I want to put my changes on top of what everybody else has done." In this sense, using git pull with the --rebase flag is even more like svn update than a plain git pull. In fact, pulling with --rebase is such a common workflow that there is a dedicated configuration option for it: 
$ git pull --rebase remote  

Github SSH login

Generating SSH keys for github
1. Open Terminal.
2. Paste the command below, substituting in your GitHub email address.
# ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
3. When you're prompted to "Enter a file in which to save the key," 
Give below mentioned path
/home/USERNAME/.ssh/id_rsa_github 
Note: USERNAME in above path is you Linux system user with which you have logged in.
Generating public/private rsa key pair.
Enter a file in which to save the key (/home/USERNAME/.ssh/id_rsa):/home/USERNAME/.ssh/id_rsa_DO_github
4. Hit enter when it asks to enter passphrase
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

Set SSH private key for github.com login

1. Go to users ssh directory
# cd ~/.ssh
# ls
2. Open or create config file and update it with below mentioned content
# vi config
Host github.com 
HostName github.com
IdentityFile ~/.ssh/id_rsa_DO_github
User git
IdentitiesOnly yes

Add SSH public key in github account

1. Copy public key
# cat ~/.ssh/id_rsa_DO_github.pub
2. Login to github with the same email id you provided while create ssh keys
Click on settings => SSH and GPG keys => New SSH key => Give a name => Paste the public key content => Add SSH keys

3. Test the login
# ssh -T git@github.com
You should get a reply as below
Hi Username! You've successfully authenticated, but GitHub does not provide shell access.

Summary

1. Version control systems are a category of software tools that help a software team manage changes to source code over time.
2. Version control software keeps track of every modification to the code in a special kind of database. 3. Git is a Distributed VCS, a category known as DVCS, more on that later. Like many of the most popular VCS systems available today, Git is free and open source.
4. Git a retain long-term change history of every file.Traceability, being able to trace each change made to the software and connect it to project management and bug tracking software such as JIRA.
5. Branching and merging. Having team members work concurrently is a no-brainer, but even individuals working on their own can benefit from the ability to work on independent streams of changes. 

Comments