9 ms·
I sort of take issue with this statement: “git is bad for me because it makes assumptions about how I work that don’t match how I actually work” I think that
by pyre 17y ago
I sort of take issue with this statement:
“git is bad for me because it makes assumptions about how I work that don’t match how I actually work”
I think that it's the other way around. git was built with a specific type of workflow in mind. If you take git and try to insert it into your current workflow with a minimal understand of git (or its intended workflow), then isn't it really you that are making assumptions about how the tool works, rather than the tool make assumptions about how you work?
{edit}
- I make a one-line change to a single file.
- I commit my change.
- I git push, only to be told “! [rejected] master -> master (non-fast forward)”.
(This is git’s cuddly way of telling you to do a pull first.)
- I git pull, only to be told
“CONFLICT (content): Merge conflict in filename.
Automatic merge failed; fix conflicts and then
commit the result.”
This is because you've created your local tree as such:
A-B-C
And the remote tree looks like:
A-B-D
When you run a 'git pull' it's a combination of two operations:
1. 'git fetch' or 'git remote update' which updates your local
copy of the remote tree. This is stored locally in the branch
<origin_name>/<branch_name> (e.g. origin/master).
2. 'git merge <branch_name> <origin_name>/<branch_name>' most
of the time this merge is a fast-forward merge which you don't
notice at all. It's when your local commit 'C' has conflict
with remote commit 'D' that you run into an issue.
In the end your tree will look like:
A-B--D--E
\_C_/
Where E is a commit with that resolves the conflict and has two parent commit IDs which point at D and C. In general, you want to just avoid this kind of stuff in the first place by either using rebase or doing the 'git pull' before you commit you changes, then push them out.
[ I'm having a hard time picturing how you would have resolved this with SVN. If you have a conflict between a local file and an update that you are pulling down with 'svn up' what happens? (I've not used SVN extensively) ]
{edit}
> Well, darn. So, OK, no problem, I already fixed the conflict, so now I’ll just git merge again to get it to make its world consistent, right? Nope: “fatal: You have not concluded your merge. (MERGE_HEAD exists)”. Well, duh! I was telling you to merge, you stupid git. You’re the branches-and-merges-are-easy version-control system around here.
You're telling git to start a new merge, not complete an in-progress merge. Think of 'git merge' as 'create a commit that merges these two things together.' When you run into a conflict 'git merge' tells you, "Sorry I couldn't automatically resolve this for you, but I got you as far as I could go. You'll have to manually resolve these conflicts and create the merge commit." At this point your working directory is in a state of 'middle of a merge.' You just have to resolve the conflicts that were pointed out to you (adding them to the index once they are resolved), and run a 'git commit' to push out the merge commit.
- jrockway 17y ago"svn update" will randomly delete your work with no way to ever get it back. I don't think new git users migrating from svn actually understand that they can rollback any changes git makes. If a pull goes bad and you don't want to deal with it, just reset to your last head. All is forgotten until you feel like fixing it. And no data is ever lost. (svn loses data by merging everything it can with your uncommitted changes, and then barfing when it can't do the merge. You're left with a bunch of conflicted file, and a bunch of merged files, with no way to ever get the unmerged files again. With git, this simply cannot happen. Git will not touch untracked files or unstaged changes, it will just die. And what it does automatically merge can be unmerged with reset. Or, you can commit the conflict markers to a separate branch, deal with it later, undo that commit, and move on with your life. Git makes easy things a little harder, but hard things easy. Subversion makes anything except hair loss very difficult.) Oh, and also, the OP really wants his tree to end up like: A--B--D--C This can be achieved with "git pull --rebase" (or automagically with the config key branch.<name>.rebase = true). That is what Subversion does, modulo the ability to revert to your original branch.
- barrkel 17y agosvn update has never randomly deleted my work, but then I never willingly do an svn update with local changes. svn update with local changes gives me this dialog: Conflict discovered in 'test.pas'. Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: However, I would normally just abort at this point, and make sure my local changes are packed up into a diff like they should be.
- jrockway 17y agoSo basically, you've written your own revision control system that integrates with Subversion. Fine.
- thenduks 17y agoWell, this begs the question, why not just let git do all that diff-packing and 99% of the conflict resolution crap for you? As long as you don't mind spending a weekend or a few evenings reading about the new tool and how it works (like any new addition to your skillset), that is.