...
A conflict occurrs when two people make overlapping changes.
Detected They are detected when you attempt to update your working copy via git pull.
You may discard your changes, discard the repository changes, or attempt to correct things manually.
If you attempt to pull in changes that conflict with your working tree, you will see an error similar to the following:
Code Block |
---|
$ git pull |
...
remote: Counting objects: 5, done. |
...
remote: Compressing objects: 100% (3/3), done. |
...
remote: Total 3 (delta 2), reused 0 (delta 0) |
...
Unpacking objects: 100% (3/3), done. |
...
From /Users/lars/projects/version-control-workshop/work/repo2 |
...
4245cb6..84f1112 master -> origin/master |
...
Auto-merging README |
...
CONFLICT (content): Merge conflict in README |
...
Automatic merge failed; fix conflicts and then commit the result. |
To resolve the conflict manually:
- (1) Edit the conflicting files as necessary.
To discard your changes (and accept the remote repository version):
- run ``git (2) run {{git checkout --theirs README``README}
To override the repository with your changes:
- (3) run
git checkout --ours README
When you complete the above tasks:
- (4) add the files with
git add
- (5) commit the changes with
git commit
.
...
Log, Tags, and Branches
Viewing history
The git log command shows you the history of your repository:
Code Block |
---|
git log [PATH] |
documentationgit log
with no arguments shows you the commit messages for each revision in your repository:$
Code Block |
---|
$ git log |
...
commit 7c8c3e71893d7481fdd9c13ec8f53cb9c61fac50 |
...
Author: Lars Kellogg-Stedman <lars@seas.harvard.edu> |
...
Date: Thu Mar 18 12:46:46 2010 -0400 |
...
changed GNU to Microsoft
...
changed GNU to Microsoft commit 257f2f3ff44c2165c1182d3673a825fcadf121aa Author: Lars Kellogg-Stedman <lars@seas.harvard.edu> |
...
Date: Thu Mar 18 12:46:46 2010 -0400 |
...
made a change
...
made a change commit 99c4fb8f37e48284d79c7396aaf755b514d6a249 Author: Lars Kellogg-Stedman <lars@seas.harvard.edu> |
...
Date: Thu Mar 18 12:46:45 2010 -0400 |
...
made some changes
...
made some changes commit 20cc63576f7c88541f5b9471e20f4d1c5f8afcb9 Author: Lars Kellogg-Stedman <lars@seas.harvard.edu> |
...
Date: Thu Mar 18 12:46:45 2010 -0400 |
...
initial import
|
Tagging and branching
Git has explicit support for tagging and branching.
git tag manipulates tags
git branch and git checkout manipulate branches
git: Tags
...
git tag -a TAGNAME
Creates a lightweight tag (an alias for a commit object)
Add -a to create an annotated tag (i.e., with an associated message)
Also possible to create cryptographically signed tags
documentationgit:
Tags
List tags:
Code Block |
---|
git tag |
Information about a specific tag:
...