Skip to main content



      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 16:50 Go to next message
Eclipse UserFriend
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 17:38 Go to previous messageGo to next message
Eclipse UserFriend
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 04:19 Go to previous messageGo to next message
Eclipse UserFriend
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 04:54 Go to previous messageGo to next message
Eclipse UserFriend
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 10:58 Go to previous messageGo to next message
Eclipse UserFriend
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 05:11 Go to previous messageGo to next message
Eclipse UserFriend
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 08:53 Go to previous messageGo to next message
Eclipse UserFriend
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 03:00 Go to previous message
Eclipse UserFriend
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: Sun Jun 15 18:33:18 EDT 2025

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

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

Back to the top