0% found this document useful (0 votes)
2 views

Assignment-merge

The document details a series of Git commands executed in a project, showcasing branch creation, switching, and merging. It highlights the process of handling changes in files across different branches and resolving merge conflicts. The final state confirms the successful merging of changes from two branches into the master branch.

Uploaded by

harissshk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment-merge

The document details a series of Git commands executed in a project, showcasing branch creation, switching, and merging. It highlights the process of handling changes in files across different branches and resolving merge conflicts. The final state confirms the successful merging of changes from two branches into the master branch.

Uploaded by

harissshk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ git branch

* master

new-feature

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ git checkout -b branch1

Switched to a new branch 'branch1'

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch1)

$ echo "Hello, this commit from Branch1" >> sample.txt

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch1)

$ git branch master

fatal: a branch named 'master' already exists

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch1)

$ git checkout master

M sample.txt

Switched to branch 'master'

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ git status

On branch master

Changes not staged for commit:

(use "git add <file>..." to update what will be committed)

(use "git restore <file>..." to discard changes in working directory)

modified: sample.txt
no changes added to commit (use "git add" and/or "git commit -a")

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ git checkout -b branch2

Switched to a new branch 'branch2'

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)

$ echo "This commit from Branch 2" >> sample.txt

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)

$ git branch branch1

fatal: a branch named 'branch1' already exists

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)

$ git checkout branch1

M sample.txt

Switched to branch 'branch1'

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch1)

$ git commit -m "Modified from Branch 1"

On branch branch1

Changes not staged for commit:

(use "git add <file>..." to update what will be committed)

(use "git restore <file>..." to discard changes in working directory)

modified: sample.txt

no changes added to commit (use "git add" and/or "git commit -a")

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch1)


$ git add .

warning: in the working copy of 'sample.txt', LF will be replaced by CRLF the next time Git touches it

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch1)

$ git commit -m "Modified from Branch 1"

[branch1 bf2a230] Modified from Branch 1

1 file changed, 2 insertions(+)

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch1)

$ git merge branch1

Already up to date.

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch1)

$ git checkout master

Switched to branch 'master'

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ cat sample.txt

This is new feature

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ git merge branch1

Updating c0db83c..bf2a230

Fast-forward

sample.txt | 2 ++

1 file changed, 2 insertions(+)

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ git checkout branch2


Switched to branch 'branch2'

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)

$ git status

On branch branch2

nothing to commit, working tree clean

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)

$ cat sample.txt

This is new feature

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)

$ echo "This modification from Branch 2" >> sample.txt

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)

$ git status

On branch branch2

Changes not staged for commit:

(use "git add <file>..." to update what will be committed)

(use "git restore <file>..." to discard changes in working directory)

modified: sample.txt

no changes added to commit (use "git add" and/or "git commit -a")

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)

$ git add .

warning: in the working copy of 'sample.txt', LF will be replaced by CRLF the next time Git touches it

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)


$ git commit -m " This is from Branch 2"

[branch2 198dd38] This is from Branch 2

1 file changed, 1 insertion(+)

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (branch2)

$ git checkout master

Switched to branch 'master'

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ git merge branch2

Auto-merging sample.txt

CONFLICT (content): Merge conflict in sample.txt

Automatic merge failed; fix conflicts and then commit the result.

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master|MERGING)

$ git mergetool --tool=vimdiff

Merging:

sample.txt

Normal merge conflict for 'sample.txt':

{local}: modified file

{remote}: modified file

4 files to edit

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master|MERGING)

$ git merge branch2

fatal: You have not concluded your merge (MERGE_HEAD exists).

Please, commit your changes before you merge.


haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master|MERGING)

$ git status

On branch master

All conflicts fixed but you are still merging.

(use "git commit" to conclude merge)

Changes to be committed:

modified: sample.txt

Untracked files:

(use "git add <file>..." to include in what will be committed)

sample.txt.orig

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master|MERGING)

$ git commit -m "Merge addressed"

[master 4e948f7] Merge addressed

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ git merge branch2

Already up to date.

haris@Harish MINGW64 /d/harish/Learning/DevOps/sample-project (master)

$ cat sample.txt

This is new feature

This commit from Branch 2

You might also like