Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Help in understanding push/fetch workflow(Problems in understanding push/fetch behaviour in egit)
Help in understanding push/fetch workflow [message #817270] Fri, 09 March 2012 21:50 Go to next message
Dennis Schieferdecker is currently offline Dennis SchieferdeckerFriend
Messages: 4
Registered: July 2009
Junior Member
I hope someone can help me in understanding the egit workflow when pushing/fetching between two repositories. Maybe I am just doing something wrong, but the results I get seem to be quite unintuitive to me.


My setup is as follows:
I have PC A with a git repository.
I have PC B with a clone of the repository and a remote set to PC A (via ssh).

On both PCs, I have the same branch checked out in Eclipse, let's say <master>.

Now, I modify/add files on PC B and perform a push upstream (to PC A). Then, when I open Eclipse on PC A, I see the previous state, still labeled as <master>,<head>. The files I modified on PC B are in their old state but marked as staged - so that a commit would revert the changes pushed by PC B. To actually get the changes pushed from PC B, I have to checkout <master> or <head> again.

What I don't understand is, why when I open Eclipse on PC A, the state looks as it does. I would expect it to either be in the state pushed by PC B; or in the previous state but the changed files only marked as changed but not staged; or in the previous state but the state not labelled as <master>,<head> but as the previous commit.
Re: Help in understanding push/fetch workflow [message #817294 is a reply to message #817270] Fri, 09 March 2012 22:38 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
This has nothing to do with egit per se. In general pushing to a non-bare repository is not recommended in Git, in part for exactly this reason: push is not designed to update a working tree. Cloning a non-bare repository is also somewhat unusual. The typical pattern is to clone from and push to a bare repository (one with no index or working directory).

If you really need to move commits from one non-bare repository to another, do it in the opposite direction: pull or fetch rather than push.

More typically both non-bare repos would have been cloned from the same bare repository. Changes in the first non-bare repo are pushed to the bare repo, at which point they're available to the second non-bare repo via fetch or pull.
Re: Help in understanding push/fetch workflow [message #817579 is a reply to message #817294] Sat, 10 March 2012 09:19 Go to previous messageGo to next message
Dennis Schieferdecker is currently offline Dennis SchieferdeckerFriend
Messages: 4
Registered: July 2009
Junior Member
Ah alright. Thanks for that information. So I would set up a bare repository on PC A (it's the only one with an ssh server to connect to) and clone working copies on both PC A and PC B. Thus, the bare repository would work much like a normal central SVN repository?

In case, you are wondering about my setup: I have a PC at home (PC A) and a notebook (PC B) and I want to code on both machines on the same project.
Re: Help in understanding push/fetch workflow [message #817594 is a reply to message #817579] Sat, 10 March 2012 09:54 Go to previous messageGo to next message
Manuel Doninger is currently offline Manuel DoningerFriend
Messages: 119
Registered: October 2010
Senior Member
I have the same setup and i created accounts at Github (for public repos, open source projects etc.) and Bitbucket (for private repos).
Re: Help in understanding push/fetch workflow [message #817756 is a reply to message #817579] Sat, 10 March 2012 15:58 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
Creating a bare repo and cloning it on both hosts is probably the cleanest solution if you're modifying both clones independently . Keeping them in sync is certainly possible without the bare repo but requires more work and more care on your part, without buying you anything.

You can populate the new bare repository from one of your existing repositories pretty easily using bare fetch.

Whether you use ssh on one of your hosts, or, as Manuel suggests, github, for the bare repo depends on how secure you need it to be. Github is quite easy to use and very handy for relatively open contents. It might not be appropriate if intellectual property is involved, depending on corporate policies, and certainly it isn't appropriate if official security is an issue.

Re: Help in understanding push/fetch workflow [message #818242 is a reply to message #817756] Sun, 11 March 2012 09:11 Go to previous messageGo to next message
Dennis Schieferdecker is currently offline Dennis SchieferdeckerFriend
Messages: 4
Registered: July 2009
Junior Member
Thank you for your explanations.
I think I give Bitbucket a look as I am in need of a private repository. And if this doesn't suite my needs I will go with an additional bare repository on PC A.
Re: Help in understanding push/fetch workflow [message #819063 is a reply to message #817756] Mon, 12 March 2012 12:53 Go to previous messageGo to next message
Ondrej Medek is currently offline Ondrej MedekFriend
Messages: 23
Registered: July 2009
Junior Member
This is offtopic, but you can have a private GitHub account as well, see github.com/plans
Re: Help in understanding push/fetch workflow [message #821298 is a reply to message #819063] Thu, 15 March 2012 07:00 Go to previous message
Dennis Schieferdecker is currently offline Dennis SchieferdeckerFriend
Messages: 4
Registered: July 2009
Junior Member
No, I don't. But I now have set up a private Bitbucket repository.
Previous Topic:Cloning remote repository fails
Next Topic:Unable to Stage some Files
Goto Forum:
  


Current Time: Fri Apr 19 22:27:24 GMT 2024

Powered by FUDForum. Page generated in 0.03412 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top