22 Merge confilcts
22 Merge confilcts
Command:
1
$ vim free_memory.py
Modify code
1
2
3
4
5
6
#!/usr/bin/env python3
def main():
"""Checks if there's enough free memory in the computer."""
main()
Command:
1
$ git commit -a -m 'Add comment to main()'
Code output:
1
2
3
[master fe2fc5b] Add comment to main()
1 file changed, 2 insertions(+), 2 deletions(-)
Command:
1
$ git checkout even-better-feature
Code output:
1
Switched to branch 'even-better-feature'
Command:
1
$ vim free_memory.py
Modify code
1
2
3
4
5
6
#!/usr/bin/env python3
def main():
print("Everything ok.")
main()
Command:
1
$ git commit -a -m 'Print everything ok'
Code output:
1
2
3
[even-better-feature 6a6de99] Print everything ok
1 file changed, 2 insertions(+), 2 deletions(-)
Command:
1
$ git checkout master
Code output:
1
Switched to branch 'master'
Command:
1
$ git merge even-better-feature
Code output:
1
2
3
4
5
Auto-merging free_memory.py
CONFLICT (content): Merge conflict in free_memory.py
Automatic merge failed; fix conflicts and then commit the result.
Command:
1
$ git status
Code output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: free_memory.py
no changes added to commit (use "git add" and/or "git commit -a")
Command:
1
$ vim free_memory.py
Modify code:
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env python3
def main():
<<<<<<< HEAD
"""Checks if there's enough free memory in the computer."""
=======
print("Everything ok.")
>>>>>>> even-better-feature
main()
Modify code:
1
2
3
4
5
6
7
#!/usr/bin/env python3
def main():
"""Checks if there's enough free memory in the computer."""
print("Everything ok.")
main()
Command:
1
2
$ git add free_memory.py
$ git status
Code output:
1
2
3
4
5
6
7
8
9
On branch master
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
modified: free_memory.py
Command:
1
$ git commit
Code output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Merge branch 'even-better-feature'
Kept lines from both branches
# Conflicts:
# free_memory.py
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
# .git/MERGE_HEAD
# and try again.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# All conflicts fixed but you are still merging.
#
# Changes to be committed:
# modified: free_memory.py
Command:
1
$ git log --graph --oneline
Code output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
* 8cb5e62 (HEAD -> master) Merge branch 'even-better-feature'
|\
| * ca6de99 (even-better-feature) Print everything ok
* | fe2fc5b Add comment to main()
|/
* 4361880 Add an empty free_memory.py
* 7d1de19 Revert "New name for disk_usage.py"
* bb9bd78 Add a gitignore file, ignoring .DS_STORE files
* 30e7071 New name for disk_usage.py
* 0d5a271 Delete unneeded processes file
* 5aada26 Adding file to delete it later
* cfb2b8e Add periods to the end of sentences.
* 21e6a1a Add new disk_usage check.
This post is licensed under CC BY 4.0 by the author.