git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: Need help migrating workflow from svn to git.

From
Randall S. Becker <rsbecker@nexbridge.com>
Date
Dec 14, 2017, 21:07 UTC
Message-ID
<005801d3751f$859f6c50$90de44f0$@nexbridge.com>
In-Reply-To
<20171214130933.GA18542@raven.inka.de>
Show 9 quoted lines
> On December 14, 2017 8:10 AM, Josef Wolf wrote:
> Subject: Need help migrating workflow from svn to git.
> 
> Hello folks,
> 
> I am wondering whether/how my mode of work for a specific project
> (currently based on SVN) could be transferred to git.
> 
> I have a repository for maintaining configuration of hosts. This
repository
> contains several hundered scripts. Most of those scripts are don't depend
on
> each other.
> 
> Every machine has a working copy of the repository in a specific
directory. A
> cron job (running every 15 minutes) executes "svn update" and executes the
> scripts which are contained in this working copy.
> 
> This way, I can commit changes to the main repository and all the hosts
will
Show 13 quoted lines
> "download" and adopt by executing the newest revision of those scripts.
> (The sripts need to be idempotent, but this is a different topic).
> 
> NORMALLY, there are no local modifications in the working copy. Thus,
> conflicts can not happen. Everything works fine.
> 
> Sometimes, I need to fix a problem on some host or need to implement a
> new feature. For this, I go to the working copy of a host where the change
> needs to be done and start haking. With svn, I don't need to stop the cron
> job. "svn update" will happily merge any in-coming changes and leave alone
> the files which were not modified upstream. Conflicts with my local
> modifications which I am currently hacking on are extremely rare, because
> the scripts are pretty much independent. So I'm pretty much happy with
this
> mode of operation.
> 
> With git, by contrast, this won't work. Git will refuse to pull anything
as long
Show 7 quoted lines
> as there are ANY local modifications. The cron job would need to
> 
>    git stash
>    git pull
>    git stash pop
> 
> But this will temporarily remove my local modifications. If I happen to do
a
> test run at this time, the test run would NOT contain the local
modifications
> which I was about to test. Even worse: if I happen to save one of the
> modified files while the modifications are in the stash, the "git stash
pop" will
Show 6 quoted lines
> definitely cause a conflict, although nothing really changed.
> 
> So, how would I get this workflow with git? Is it possible to emulate the
> behavior of "svn update"?
> 
> Any ideas?

You might want to consider a slight modification to your approach as follows. Instead of using git pull, use git fetch. Have each system on its own branch (sys1 = my-sys1-branch, for example) so you can track who has what. In your scripts, consider: git fetch if nothing changed, done git status if no changes, git merge --ff master && git push origin my-sys1-branch && done if changes, send an email whining about the changes your script could then (depending on your environment) git commit -a && git merge && git push origin my-sys1-branch && done

This would allow you to track the condition of each system at your single upstream repository.

Just my $0.02

Cheers. Randall\ -- Brief whoami: NonStop&UNIX developer since approximately UNIX(421664400)/NonStop(211288444200000000) -- In my real life, I talk too much.

Previous: Josef WolfNext: Josef Wolf
Message 2 of 16 in “Need help migrating workflow from svn to git.”
  1. Josef WolfDec 14, 2017
  2. Randall S. BeckerDec 14, 2017
  3. Josef WolfDec 15, 2017
  4. Igor DjordjevicDec 14, 2017
  5. Igor DjordjevicDec 15, 2017
  6. Josef WolfDec 15, 2017
  7. Josef WolfDec 15, 2017
  8. Igor DjordjevicDec 15, 2017
  9. Junio C HamanoDec 15, 2017
  10. Igor DjordjevicDec 15, 2017
  11. Junio C HamanoDec 15, 2017
  12. Igor DjordjevicDec 15, 2017
  13. Josef WolfDec 20, 2017
  14. Josef WolfDec 20, 2017
  15. Josef WolfDec 20, 2017
  16. Igor DjordjevicDec 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.