emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: VC mode and git


From: Harald Hanche-Olsen
Subject: Re: VC mode and git
Date: Wed, 25 Mar 2015 19:04:55 +0100
User-agent: Postbox 3.0.11 (Macintosh/20140602)

Richard Stallman wrote:

As a separate matter, something is wrong in my repository with
lisp/ChangeLog.  I have changes I want to check in, and I don't know
what to do.  Brief hints are not enough to enable me to fix this.
How should I get my changes installed?

Would you please help me?

Why did you not take my advice on that other thread to post the output of “git status -s” to the list? I bet there are many people able to help, but giving step by step advice based on too little information is dangerous and could lead you into further trouble.

Here is a sample output from “git status -s”, after I made some frivolous changes:

; git s
## master...origin/master
MM ChangeLog
M  README
 M lisp/mail/rmail.el

Here, README is changed and staged for commit (it's in the index), lisp/mail/rmail.el is changed but not staged for commit, and Changelog is changed and staged for commit, then changed again and the new change is not staged for commit. (Staging for commit is typically done by “git add”.)

It is also useful to know if you have any local commits. Assuming you are on the master branch, you can run

  git log origin/master..master

If it produces no output, then you have no local commits that are not in the remote branch. If you do, more work is required to recover.

It is POSSIBLE that a safe way to recover from your problems is as follows:

  git stash
  git reset --hard HEAD
  git pull --ff-only
  git stash apply

but I don't want to be the guy who goes down in history as the one who caused you to lose your changes because you followed this advice.

Maybe, if someone with more git experience reads this and says it is good, you should go ahead. Of course, if any of the commands but the last fails, stop and ask for advice again. If the last one reports merge conflicts, fix them by hand and run “git add” on each file after you fixed it. DO NOT use C-x v v after fixing a merge conflict, since that runs both git add and git commit, and you are not ready for the latter until all merge conflicts are dealt with.

In any case, do run git status before finally doing git commit. If all succeeds, you can clean up with

  git stash drop

– Harald



reply via email to

[Prev in Thread] Current Thread [Next in Thread]