emacs-devel
[Top][All Lists]
Advanced

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

Re: best workflow with git ?


From: Alan Third
Subject: Re: best workflow with git ?
Date: Sat, 10 Jun 2017 18:14:16 +0100
User-agent: Mutt/1.7.2 (2016-11-26)

On Sun, Jun 11, 2017 at 12:04:06AM +0900, Jean-Christophe Helary wrote:
> I got the repository from Savannah and each time I want to update it
> I do a "git pull origin master". If I have worked on some files
> before that I usually get a message asking me to commit my files
> otherwise they'd be overwritten. Since I'm not pushing anything to
> Savannah I feel that committing to the local Master is useless and
> will only create discrepancies between my repository and Savannah.

I find the easiest way to deal with this is to commit the change, and
then pull using -r

    git pull -r

to rebase my unpushed commit back on the top.

I can then use

    git commit --amend

to make further changes to that commit, but make sure you NEVER amend
a commit that you’ve already pushed to the repository because that
breaks things.

If you then want to get rid of the commit you can just do

    git reset --hard HEAD~1

The number at the end represents the number of commits you want to
delete. If you only want to delete your unstaged changes (and staged
too? I’m not sure) you can do

    git reset --hard

It’s safe to delete too many commits as a git pull will bring you
right back up to date with the repository again.

An alternative I’ve used in the past is to stash the files and then
pop them back once I’ve finished with the pull, but I find committing
them locally and rebasing is often neater, especially if I have
installed someone else’s patches for testing and therefore have
multiple unpushed commits.
-- 
Alan Third



reply via email to

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