0% found this document useful (0 votes)
18 views1 page

Merging

The document outlines a series of Git commands to create a repository, make initial commits, and demonstrate a merge conflict. It describes the process of creating a new branch, editing a file to cause a conflict, and attempting to merge the branches, which results in a conflict. Additionally, it mentions commands for resolving conflicts and undoing changes.

Uploaded by

Rani Marri
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)
18 views1 page

Merging

The document outlines a series of Git commands to create a repository, make initial commits, and demonstrate a merge conflict. It describes the process of creating a new branch, editing a file to cause a conflict, and attempting to merge the branches, which results in a conflict. Additionally, it mentions commands for resolving conflicts and undoing changes.

Uploaded by

Rani Marri
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

$ mkdir git-merge-test

$ cd git-merge-test

$ git init .

$ echo "this is some content to mess with" > merge.txt

$ git add merge.txt

$ git commit –am "we are commiting the inital content"


[main (root-commit) d48e74c] we are commiting the inital content
1 file changed, 1 insertion(+)
create mode 100644 merge.txt

$ git checkout -b new_branch_to_merge_later

$ echo "totally different content to merge later" > merge.txt

$ git commit –am "edited the content of merge.txt to cause a conflict"


[new_branch_to_merge_later 6282319] edited the content of merge.txt to cause
a conflict
1 file changed, 1 insertion(+), 1 deletion(-)

$git checkout main

Switched to branch 'main'

echo "content to append" >> merge.txt

$git commit –am "appended content to merge.txt"


[main 24fbe3c] appended content to merge.txt
1 file changed, 1 insertion(+)
$ git merge new_branch_to_merge_later

auto-merging merge.txt
CONFLICT (content): Merge conflict in merge.txt
Automatic merge failed; fix conflicts and then commit the result.

git checkout
checkout can be used for undoing changes to files, or for changing
branches
git reset --mixed
reset can be used to undo changes to the working directory and staging
area.
Tools for when git conflicts arise during a merge
git merge --abort

You might also like