35 points · by reinhardt · 13y ago · 94 comments
It tells me I can lose history, but this is a revision control system, surely they don't mean I can actually lose history?
Sorry, but why did you think that they said that except to tell you that you could actually lose history? You ignored the rest of the error message and used --force. And then you were surprised that what the error message told you actually came to pass?
That's a sharp edge that should be exposed, and its not the only one in git.
Git is not really a revision tracking system.
Git is a content tracking file system manager. It happens to be the case that these two uses largely overlap, but what Git really lets you do is take snapshots of your filesystem, annotate each snap shot, and allow you to compare snapshots.
It does not keep track of your changes. You keep track of your changes when you use git by annotating each snapshot.
However on Gits' homepage: "Git is a free and open source distributed version control system".
History not referenced will eventually be reaped by the garbage collector though.
It's muscle memory and makes everything more explicit and easy to understand. Although, in this case, it sounds like you expect git to be intuitive. (Which it is not)
So this basically amounts to a blog post complaining that git is hard.
And don't even get me started on the nightmare that is submodules.
The whole thing reminds me of the bad old unix days of "if it was hard to write, it should be hard to understand."
git checkout -b new-branch
... is a shortcut for: git branch new-branch
git checkout new-branch
You can create the branch or otherwise manipulate it without actually checking it out, so it's useful to have it separate and have a shortcut.(I agree that git's interface is terrible, but I disagree that this is one of those cases. :) )
I do think this is precisely one of those cases.
"Branch" is a major, repo-modifying operation; "checkout" is a trivial context switch operation. The user interface disaster here was that the major operation is treated as subservient to the trivial operation. It should be the other way around.
Therefore, the shortcut for creating a branch and switching to it should be
git branch -c new-branch
whereby the -c switch checks you into that branch immediately.But seriously, yes, you have to learn how to use Git in order to use Git. But you don't have to use Git. Click here to renew your Visual Source Safe license, or better, just copy your file to file.1 every time you edit it. No way that can go wrong!
[0] http://visualstudiogallery.msdn.microsoft.com/abafc7d6-dcaa-...
And feminine, at that?
! [rejected] master -> master (non-fast-forward)
And once you've invoked the gods of `push -f`, you're on your own.> Of course, a less good but at least sane behavior would have been if pull also pulled matching branches by default
I don't see any way this could work in the face of potentially having merge conflicts in non-current branches.
This is why git-up was created: https://github.com/aanand/git-up
It's silly that this is necessary, but "gem install git-up" and then run "git up" instead of "git pull" and you'll be much happier.
But don't get me wrong. On the whole, git is fantastic and a real improvement on its predecessors.
If I could change one thing, it would be pushing and pulling between workstations and central repositories. Distributed is nice, but at the end of the day you still want your code to end up somewhere, and Git doesn't make that process feel smooth or robust.
>no matter how proud Torvalds is of the fact that he
>never looked at another version control system for
>inspiration
What gave you that impression? Git was strongly influenced by BitKeeper and to a much lesser extent by Monotone. And, arguably, 'anti-inspired' by several other VCS's Linus would have surely been at least passingly familiar with.I think most of the outside influence came from people who weren't Torvalds, but the command set is just so weirdly different from every other VCS (even where functionality maps nearly 1:1) that it seems likely that it was designed without much consideration for existing use patterns of other VCS'.
http://marc.info/?l=git&m=114685143200012 http://marc.info/?l=git&m=116129092117475
And two basic verbs 'pull' and 'push' are straight from BK.
My impression's been that the crazy command set is in part due to the early design idea that the basic commands represent primitives that operate on the fundamental git model on top of which something, potentially separate and more human-friendly will be built. Except it didn't quite work out that way.
git fetch <remote> <branchname>:refs/remotes/<remote>/<branchname>
git rebase <branchname> <remote>/<branchname> git branch -r
will show all the remote tracking branches I had no idea existed. Thanks a lot, git makes much more sense to me now.Just look at git.kernel.org - over 400 repos only for linux kernel. This is what git designed for - to be Mass Distributed Version Control System.
So are using it as tape archiver and wondering why defaults look so unfrendly.
It's not me, it's post author who makes it sound so. Actually it's up to user to decide what is suitable for him and what is not.
I've been through this exact battle so many times, git pull should only ask you for your branch if you've told it you want it to (as a safety measure i guess)/
1. Not only mention of the rejected `master` branch, but also the successful push of the `gh-pages` branch. Which makes it a lot more clear that git is trying to push multiple branches, and that the rejection has to do with `master` and not `gh-pages`.
2. The push default of `matching` is changing soon in upstream git (because it is suitable for certain types of workflow, but can cause confusion, as seen here), and the last several versions complain loudly if you do not set the default. This is intended to call attention to this common pitfall, and to notify users so that they are not surprised by the change when it happens.
With git v1.8.2, here is the full output of `git push` in his situation (you may note that the non-fast-forward advice has been improved, too):
$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (6/6), 428 bytes, done.
Total 6 (delta 0), reused 0 (delta 0)
To /home/peff/foo/die-git-die/parent.git
148db6f..25cd4ef pages -> pages
! [rejected] master -> master (fetch first)
error: failed to push some refs to '/home/peff/foo/die-git-die/parent.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.EasyGit also provides better built-in documentation. For example, if you get merge conflits, `eg status` will mention that you can run `eg help topic middle-of-merge`. That command opens a page explaining your options – how to find conflicts, resolve conflicts, etc. I have found EasyGit very useful, and when it’s installed, I always use `eg` instead of `git`. You can download the EasyGit script at the linked website, or install it using Homebrew with `brew install easy-git`.
Code section 5 and 6 are apparently modifying the code branch, and the pages branch, respectively, but doing so in separate local clones of the repo. I think there's a typo in code section 6, where I think he meant to start with
cd ../die-git-die.pages
This doesn't seem like a situation where multiple local git repos are needed. What's wrong with managing both branches from one local repo?A separate folder for the gh-pages branch makes sense because this branch has nothing in common with any of the other branches. It doesn't share any code or commits with your master branch.
The repository actually has two base commits and it's like two repositories contained in one. Thus needing two separate folders.
I think that if you had changed the above to
$ git push -u origin gh-pages
then everything else would have gone smoothly.Moreover, any loss that does occur is recoverable as long as you keep your clone around. Git doesn't garbage collect refs for at least 30 days. So you're pretty protected if you clone to a location that has regular backups.
My point is not that git is impossible to use. It's that the way git behaves by default is insane.
A common mistake people make when bitching about Git, is assuming that their workflow is the only workflow. Git supports a multitude of different workflows, and that fact is both a strength and a weakness.
That it deletes history without somebody issuing an explicit specific command to delete a specific revision is not a matter of workflow, it's bad design.
Looks like it was inspired by a hackernews comment https://news.ycombinator.com/item?id=2684483 and it replaces these commands
It's kinda like you're using wget to surf the web, and complaining that it doesn't have a GUI.
parent comment is arguing that the command-line interface is nontrivial, which is a fair criticism. Contrast with 'cp' or 'mv'
Git user interface is fine when you finally learn how to use git.
The result is that it behaves unpredictably and confusingly. And that's a bad UI, no matter how powerful things are below.
"Git developers don't care about newbie users who can't even bother to RTFM."
This is probably true.
"There is just no reason they should."
Yes there is.
I don't think your reasoning holds. That's why we have abstractions, to make hard things easy.
Github is the one who wants you to use git. This is why github built you a gui.
man gittutorial