Tuesday, May 18, 2021

GIT Basics - Automatic Merges

Let's create a simple scenario

1.create new branch 'simple-branch' and create a file  and commit there

2. switch to 'master' branch and update file  there

3. merge content to 'master' branch


git status -> verify clean

git checkout -b simple-branch

git mate simplefile

git commit -am "adding a new line"

git checkout master

git mate README.md

git commit -am " add instructions on deployment"

git log --online --graph --decorate --all

git branch -> you will two  branches '*maste' and 'simple-branch"

git merge simple-branch -m "merge chnages from simple-branch"

repeat log command

git log --online --graph --decorate --all

you can see the merge comment/commit and simple-branch keep as a seperate branch

git branch --> verify

let's remove

git branch -d simple-branch


See the log

git log --online --graph --decorate --all

only label "simple-branch" being removed

branch itself is still  intact


you can verify the merge by going to two files

README.md and simplefile -> you can see the changes

No comments:

Post a Comment