Enable Dark Mode!
what-is-git-rebase.jpg
By: Swapna

What is Git Rebase?

Technical

Here we are discussing the git rebase. As we all know that git may be a version system to simply track the changes within the file.  We are storing files within the git repository. If you wish to create any changes, first must pull the file from the repository to your system. And make changes as required. Then push the changes to the repository. 
Basically, all the files in an exceeding repository are located within the default branch. So you must have to work with branches. We are able to create feature branches for our needs. Once you create a feature branch, we will pull and pass on that branch.
What is rebase?
Rebase could be a method to maneuver or combine our new commits supporting new base commits. (i.e,) make changes to a branch supporting a base branch. Have 2 sorts of rebase ( regular rebase and interactive rebase)
Let’s observe the steps to rebase a branch.
Regular rebase :
Create a folder in your system and open it within the terminal. Type the subsequent.
1. git init
2. git remote add origin {cloning link of your default branch}
3. git clone {cloning link of your default branch}
4. cd {folder_name}
Here moving to a subfolder
5. git fetch origin {default_branch}
Here we are fetching the most recent changes from the default branch.
6. git checkout {feature_branch}
7. git rebase origin/{default_branch}
8. git push --force origin {feature_branch}
Interactive rebase :
An interactive rebase is employed to switch recent commits.
Here we are using “--interactive” or “-i” flags.
For example, we are visiting to change the last 4 commits in your branch.
git rebase -i HEAD~4
This command is employed to induce all the last 4 commits in your terminal. together with that, we get all the rebase options. Following are a number of them.
# Rebase 2ce55d7, 18e4as onto 1804a6b (4 commands)
# Commands: 
# P, pick commits use connit
# r, reword commits use connit, but edit the commit message
# e, edit commit> use connit, but stop for an ending
# s, squash commit use connit, but neld into previous commit effleup commit like "squash, but discard this commit's log message 
# x, exec <command> run command (the rest of the Line) using shell
# b, break stop here (continue rebase later with git rebase-continue")
# d, drop cornit remove commit
# l, label <label> label current HEAD with a name t, reset <label>= reset HEAD to a label
# m, merge [-C commit. c commit>] <label> [= coneline>]
create a merge commit using the original merge commit message (or the oneline, if no original merge content was specified). Use c«commit to reword the commit message. 
# These lines can be re-ordered; they are executed from top to bottom.

# If you remove a Love here THAT COMMIT WILL BE LOST.

# However, if you remove everything, the rebase will be aborted.
# Note that empty commits are commented out
‘pick’ is the alternative. While using a pick, the commit remains unchanged.
‘reword’ is employed before editing each commit message.
‘edit’ is employed to prevent amending.
‘squash’ combines new commits with the previous commits.
‘fixup’ operation will keep the first message and discard the message from the fixup commit.
‘exec’ operation is employed to run/execute the commits.
‘Break’ operation is employed to interrupt the rebase process.
‘drop’ operation is employed to drop/ delete the rebase process.
‘label’ operation is employed to label commits.
‘reset’ operation is employed to vary the recent commit message.
‘merge’ operation is employed to merge the commits with the parent branch.
There are plenty of options including reword, edit, squash, fixup, exec, break, drop, label, reset, merge, and so on. we will use the choices as per our needs.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment

 


whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message