all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* best workflow with git ?
@ 2017-06-10 15:04 Jean-Christophe Helary
  2017-06-10 15:23 ` Dmitry Gutov
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jean-Christophe Helary @ 2017-06-10 15:04 UTC (permalink / raw)
  To: emacs-devel

I'm not used to git and I see that I'm not doing the right thing locally. I'd like to know the workflow that would work the best for what I'm doing.

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.

What should I do ? Create a branch where I do all my modifications ? And then do a git diff to create a patch that I send here ? When the patch has been applied, what should I do with the branch and the modified files ?

It looks like there is something I'm not getting right and I'd like to know what it is. Thank you in advance.

Jean-Christophe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: best workflow with git ?
  2017-06-10 15:04 best workflow with git ? Jean-Christophe Helary
@ 2017-06-10 15:23 ` Dmitry Gutov
  2017-06-10 15:40 ` Ingo Lohmar
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Dmitry Gutov @ 2017-06-10 15:23 UTC (permalink / raw)
  To: Jean-Christophe Helary, emacs-devel

On 6/10/17 6:04 PM, Jean-Christophe Helary wrote:

> What should I do ? Create a branch where I do all my modifications ? And then do a git diff to create a patch that I send here ? When the patch has been applied, what should I do with the branch and the modified files ?

If the changes are minor and not ready to commit, I usually do 'git 
stash save' and 'git stash pop' after the pull.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: best workflow with git ?
  2017-06-10 15:04 best workflow with git ? Jean-Christophe Helary
  2017-06-10 15:23 ` Dmitry Gutov
@ 2017-06-10 15:40 ` Ingo Lohmar
  2017-06-10 17:11 ` Eli Zaretskii
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ingo Lohmar @ 2017-06-10 15:40 UTC (permalink / raw)
  To: Jean-Christophe Helary, emacs-devel


Hi Jean-Christophe,

On Sun, Jun 11 2017 00:04 (+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.

if you only update to "have" the changes in your repository (not in your
working tree), you could just substitute "pull" by "fetch" (try it -- no
danger at all).

If you are working on changes you plan to submit later, committing to
your local master (or a branch, if you prefer) is perfectly fine.  You
can still add changes to such commits later, if you have not yet pushed
them out.

It can also help to change your point of view: After all, the
"discrepancies" between your repository and Savannah are not a problem
to avoid --- they are the essence of your work. :)  Local commits are
just a more powerful and flexible way to handle these changes (compared
to changing files in your working tree).

HTH,
Ingo



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: best workflow with git ?
  2017-06-10 15:04 best workflow with git ? Jean-Christophe Helary
  2017-06-10 15:23 ` Dmitry Gutov
  2017-06-10 15:40 ` Ingo Lohmar
@ 2017-06-10 17:11 ` Eli Zaretskii
  2017-06-10 17:14 ` Alan Third
  2017-06-11  8:43 ` Philipp Stephani
  4 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2017-06-10 17:11 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel

> From: Jean-Christophe Helary <jean.christophe.helary@gmail.com>
> Date: Sun, 11 Jun 2017 00:04:06 +0900
> 
> 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.
> 
> What should I do ? Create a branch where I do all my modifications ?

For a long-term development, yes.  For short-term jobs, I' like
Dmitry, use "git stash".  (And in many cases "git pull" will not even
ask for that, so I don't need to do anything.)

> And then do a git diff to create a patch that I send here ?

Yes.

> When the patch has been applied, what should I do with the branch and the modified files ?

You could delete the branch.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: best workflow with git ?
  2017-06-10 15:04 best workflow with git ? Jean-Christophe Helary
                   ` (2 preceding siblings ...)
  2017-06-10 17:11 ` Eli Zaretskii
@ 2017-06-10 17:14 ` Alan Third
  2017-06-11  8:43 ` Philipp Stephani
  4 siblings, 0 replies; 6+ messages in thread
From: Alan Third @ 2017-06-10 17:14 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: best workflow with git ?
  2017-06-10 15:04 best workflow with git ? Jean-Christophe Helary
                   ` (3 preceding siblings ...)
  2017-06-10 17:14 ` Alan Third
@ 2017-06-11  8:43 ` Philipp Stephani
  4 siblings, 0 replies; 6+ messages in thread
From: Philipp Stephani @ 2017-06-11  8:43 UTC (permalink / raw)
  To: Jean-Christophe Helary, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2296 bytes --]

Jean-Christophe Helary <jean.christophe.helary@gmail.com> schrieb am Sa.,
10. Juni 2017 um 17:04 Uhr:

> I'm not used to git and I see that I'm not doing the right thing locally.
> I'd like to know the workflow that would work the best for what I'm doing.
>
> 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.
>

Yes, don't commit to local master. A common workflow is to do all work in
local branches.


>
> What should I do ? Create a branch where I do all my modifications ?


Yes, exactly. Typically you start with
git checkout master
git pull --ff-only
git checkout -b topic-branch master
# now work on the topic branch
git commit

If the topic branch gets too old, you should rebase it:

git checkout master
git pull --ff-only
git rebase master topic-branch


> And then do a git diff to create a patch that I send here ?


Yes, but use git format-patch (or git send-email to send the mail directly):

# Maybe rebase as above
git checkout topic-branch
git format-patch master


> When the patch has been applied, what should I do with the branch and the
> modified files ?
>

Rebase one more time, then delete the branch:
git checkout master
git pull --ff-only
git rebase master topic-branch
git checkout master
git branch -d topic-branch

If the patch has been applied, the topic branch will be identical to
master, and Git will immediately delete it. Otherwise it will not delete
it, and there are some changes that are not yet in master.

Once you get commit access to Savannah, you can also push yourself to
master:
git checkout master
git pull --ff-only
git rebase master topic-branch
git checkout master
git merge topic-branch --ff-only
git push

This workflow works well, allows you to work on many topics in parallel,
and keeps history clean. The maybe somewhat non-obvious rule is to always
rebase the topic branches and fast-forward master; you can use 'git config
merge.ff only' to disallow all non-fast-forward merges.

[-- Attachment #2: Type: text/html, Size: 3440 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-06-11  8:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-10 15:04 best workflow with git ? Jean-Christophe Helary
2017-06-10 15:23 ` Dmitry Gutov
2017-06-10 15:40 ` Ingo Lohmar
2017-06-10 17:11 ` Eli Zaretskii
2017-06-10 17:14 ` Alan Third
2017-06-11  8:43 ` Philipp Stephani

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.