brothersvilla.blogg.se

Git pull remote branch and rebase
Git pull remote branch and rebase








git pull remote branch and rebase

Let us take an example if we have a project with 3 commits on the master branch as commit 1,2,3 and feature branch commits as commit A and B.

git pull remote branch and rebase

Git merge is one of the merging techniques in git, in which the logs of commits on branches are intact. Now, that we understand merging, let’s understand the different types of merging that we can perform in git.

#Git pull remote branch and rebase code#

Commit 4 on the master, has all the changes of the code i.e Commit 1,2, 3, A, and B. We merged the feature branch on master, resulting in commit 4. Similarly, since the feature branch was branched out from master on commit ‘2’, it has code changes from Commit 1,2, A, and B, but it does not have changes from Commit 3 on master.īelow, we have merged the feature branch on master, let us understand what happened. In the current scenario, the master branch has the code of Commit 1,2 and 3, but it does not have changes of Commit A and B from the feature branch. We also did some changes on the master branch, in the form of commit 3. Later, we did some changes in the feature branch in the form of commits A and B. We created a feature branch, after commit ‘2’ on master. In Fig 7: before merging, we can see that there are some commits on the master branch. Blue commits are on the master branch, and yellow commits are on the feature branch. So let us take an example from the diagram below, which shows the status before and after merging of two branches, feature and master branch. Git Merge is a technique that is used to include the changes from one branch to the other branch. In general, merging means combining something into a single entity. If you don’t understand merging don’t worry everything will be clear in the next section. If we consider the above website example after merging changes can be seen in the diagram below:įig 6: After merging the changes into the master branch changes were depicted on the website.

git pull remote branch and rebase

And now, the changes which were made in the feature branch will exist on the master branch as well.įig 5: Merging of feature branch with the master branch Once you are done with the changes, we simply ‘merge’ the changes of the ‘feature’ branch to the ‘master branch’. Now, any new changes that you will do on the feature branch, will not affect the code on the master branch.įig 4: Master branch and the Feature branch So, we create a new branch from the master branch, let’s call it a ‘feature branch. Now, we don’t want to touch the master branch code, we want to copy the code of the master branch to a new place, where we can experiment or change the code. So, the website we showed you above is the master branch. By default, all your code is stored on a master branch. So, in git to isolate different versions of code we have branches. Make changes in the code, and then once the changes are finalised, you will replace the code in the main folder right? Let us understand how we can do the above thing in git. So, what do you do? Ideally, you will copy the code of this website in a new folder. But if you are changing the code, you do not want the changes to be reflected in the main website which is deployed. For this, you will have to change the code of the website. You want to add more features to this website. The website looks something like this.įig 3: Sample example of the website before changes Let us take an example to understand this, Let’s say you have a website that is currently running. So whenever we make any change, it generates a new commit.įig 2: The changes made in the repository will be saved as a new commit with a new commit id What is a Branch?Ī Branch is a representation of different isolated versions of code. These changes in git will be saved as another commit with another commit-id 14343. Now let us say we have made some changes to the code by adding another python file. Each commit has a commit-id, let it be 1234 in our case. These four python files will be saved inside a commit. In Fig: 1, Let us assume that we have four python files. Let us take an example and discuss in brief from the diagram shown below:įig 1: The changes made are saved in a commit What is a Commit?Ĭommit is defined as the location where the code and its changes are stored.

git pull remote branch and rebase

Let’s understand these two terms respectively. How can Git Rebase and Git Merge be used together?įor understanding the working of git, we need to understand the two fundamental concepts in git which is git commit and git branch.So, the following are the topics covered in this blog:










Git pull remote branch and rebase