Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » [solved] check in/out problem
[solved] check in/out problem [message #750389] Tue, 25 October 2011 15:21 Go to next message
Bit2_Gosu  is currently offline Bit2_Gosu
Messages: 6
Registered: October 2011
Junior Member
Hi,

Today is my first day with egit Wink I have a remote repository at "google code". I had a local project which i pushed to the remote rep.
I then deleted the local project and used "file -> import -> projects from git" to pull the project from the remote rep. For this i cloned the remote project.
I now have a local project with "[name of the remote rep.]" behind it's name. I hope this local project is now "connected" with the remote one.
I now want to use synchronize to check out/in. However this doesn't quite work. In order to see remote changes i have to go to "synchronize -> git -> [name of remote rep.] as repository and the remote branch as destination -> finish.
Only then does the synchronize view see the remote change (blue arrow). And there are no black arrows if i change a file locally. I therefore have to push in order to get the local changes to the remote rep..

Somehow I seem to be doing things a little wrong. Can someone help?

[Updated on: Mon, 31 October 2011 14:47]

Report message to a moderator

Re: check in/out problem [message #750501 is a reply to message #750389] Tue, 25 October 2011 16:29 Go to previous messageGo to next message
Dariusz Luksza is currently offline Dariusz Luksza
Messages: 40
Registered: July 2010
Member

If you want to synchronize with yours origin/default remote repository simply choose Team -> Synchronize Workspace from project's context menu.

If you change something in working directory (it mean in yours project shared by git) then such change should immediately snow in synchronization results (if synchronization for this repository was launched before change occurs). Of course changes will also appear in sync results when you launch synchronization process after save action. If you will use pull action then you'll never see any incoming changes in sync view, during pull process all incoming changes are immediately merged into current branch.
Re: check in/out problem [message #750627 is a reply to message #750501] Tue, 25 October 2011 17:29 Go to previous messageGo to next message
Bit2_Gosu  is currently offline Bit2_Gosu
Messages: 6
Registered: October 2011
Junior Member
Talking about checking in:
I'm trying to check in/out by using "team -> advanced -> synchronize -> refs/remote/origin/master". If I change something in my working directory and commit there appears a black arrow in the synchronized view. However I don't know how to get this change into the remote repos. I thought clicking "commit" would do just that in the "team -> advanced -> synchronize -> refs/remote/origin/master" view.
Talking about checking out:
If i make an external change in a file from remote repos there appears a blue arrow in "team -> advanced -> synchronize -> refs/remote/origin/master" - this is what i excpected. However if my worspace file is also changed, there is a conflict - this is what i excpected. If copy the line that was changed in remote repos "from right to left" and say "mark as merged" then "commit"
the arrow becomes RED. Why? If I now copy the whole file from right to left, so that local version equals remote version the arrow remains red..

Maybe you can help me about these 2 issues. I have no longer tried to use pull or push now.
Re: check in/out problem [message #752016 is a reply to message #750627] Wed, 26 October 2011 04:39 Go to previous messageGo to next message
Dariusz Luksza is currently offline Dariusz Luksza
Messages: 40
Registered: July 2010
Member

Commit action affects only yours LOCAL repository (you must consider that using git you have local and remote repositories). To interact with remote repos use pull/push/fetch commands.

Fetch command will fetch remote changes into yours local repository. Remote changes are stored in refs/remote/$remote_name/$remote_branch_name (eg. refs/remote/origin/master for branch master from origin repository). To "check in" those remote changes you need to use merge/rebase commands not. commit (commit action is only used when you have some conflicts).

Pull command will fetch remote changes and automatically merge/rebase (depends on yours configuration) those remote changes into local branch.

Push action will send yours changes back to remote repository.

The git workflow looks something like this:
edit -> add to index -> commit locally -> push to remote

Git behaves different then cvs/svn eg. you cannot move right to left single change, you need to merge whole commit because commits are connected with each other. I would recommend you reading ProGit[1] book to better understood how git really works.

[1] http://progit.org/book/
Re: check in/out problem [message #753565 is a reply to message #752016] Thu, 27 October 2011 14:02 Go to previous messageGo to next message
Bit2_Gosu  is currently offline Bit2_Gosu
Messages: 6
Registered: October 2011
Junior Member
Hi again and thanks for your help so far,

I have now spent 1 day reading a lot about git. I could now push to remote by using "push to upstream". I configured my upstream as fetch/heads/* : fetch/heads/*. Push worked, so my local branch was now identical to the branch in the remote repos.

HOWEVER i still have a problem with fetching: I changed a file in the remote repos. I then said "fetch from upstream". I configured my upstream as refs/heads/* : refs/remotes/origin/*.
If I am correct, this means that all changes in the remote repos will replace my local stuff in my remote branch called origin.
Indeed he found the change that was made. I went to "advanced -> synchronize -> refs/remotes/origin/master". If I am correct this means that I want to synchronize my remote branch called master with the remote repos at github.com. Indeed he showed me a blue arrow and the change i made at github.com. If I am correct I should now attempt a merge which would be a fast-foward merge. I clicked merge. The blue arrow remained. I now clicked "add" and then "commit". After that both versions in the synchronize view where identical and my working space version, too. But in the synchronize view there is now a RED arrow. (I now can't push to upstream anymore - message: "rejected".)

What am I still doing wrong?

[Updated on: Thu, 27 October 2011 17:24]

Report message to a moderator

Re: check in/out problem [message #753586 is a reply to message #753565] Thu, 27 October 2011 17:32 Go to previous messageGo to next message
Dariusz Luksza is currently offline Dariusz Luksza
Messages: 40
Registered: July 2010
Member

"refs/heads/* : refs/remotes/origin/*" means, fetch all remote branches to local ref/remotes/origin
"advanced -> synchronize -> refs/remotes/origin/master" means, compare my local working copy (or locally checked branch) with refs/remotes/origin/master

Honesty, I wouldn't recommend you use sync view to merge commits because effect of such action can be surprising for you. In most cases call 'merge' on single file will also affect rest 'incoming' files (since you need to merge-in all commit, not particular change in file). The only case when you need to use 'add' and 'commit' *while* merging is when you had some conflicts and you resolve them, in such situation by 'add' you inform git that all conflicts in particular file was resolved and 'commit' action indicates that all conflicts were resolved.

Currently sync view works for outgoing changes (you can commit them and then push to remote) and as review tool for incoming changes. We need to improve some thing to make synchronize view usable in both cases ... one of such thing is figuring out how to inform user that merging single file will affect all other files ...
Re: check in/out problem [message #753596 is a reply to message #753586] Thu, 27 October 2011 18:29 Go to previous messageGo to next message
Bit2_Gosu  is currently offline Bit2_Gosu
Messages: 6
Registered: October 2011
Junior Member
Hey Dariusz,

just as you wrote your post I finally got things working perfectly.. WITHOUT synchronize view. Indeed I don't know if synchronized view isn't even buggy for incoming changes.
How it works fine: Fetch from upstream, then in normal(!) view say team -> merge. If local head points to predecessor of ref/remotes/origin than we get easy fast foward merge. If neither commit is predecessor of other, then egit informs me of merge conflict and i can got to team -> merge tool to change my working copy. Then go to team -> add (which is multi purpose command that in this case seems to equal "mark as merged") and then team -> commit. Yesss!

How it doesn't work at all: What I tried to do all the time: After fetch from upstream i went to team -> advanced -> synchronize. I chose "refs/remotes/origin/master" because i wanted to synchronize working copy with remote tracking branch. The synchronize view did a great job in signalling incoming and outgoing changes. In case of a conflict i modified my working copy and then still in the synchronize view said "merge" after right-click on project. However this merge behaved completely different from merge you get throug team -> merge in normal view. it RUINS everything. If you say "add" then "commit" the synchronize view will always show red marker for conflicts, which must have sth. to do with fact that the new commit has no remote tracking branch.. because how can you synchronize your working copy with a remote tracking branch if there is none (for whatever reason). I really don't understand why this synchronize merge behaves so differently and what it actually does.
Re: check in/out problem [message #753847 is a reply to message #753596] Sat, 29 October 2011 07:45 Go to previous messageGo to next message
R Shapiro is currently offline R Shapiro
Messages: 378
Registered: June 2011
Senior Member
Just for reference. the 'add' command in Git (and egit) always has the same purpose: it adds changes to the Index. The Git/egit merge command also adds changes to the Index. If there are no conflicts it then commits those changes. If there are conflicts, then of course you have to 'add' the resolutions yourself, and then commit. There _is_ a logic to the Git command set, it's just a little convoluted.

As for the synchronization view,it's a work in progress. For now I would say it's best used only to view differences between branches, and even then only in relatively small repositories (too slow otherwise). It plays a very different role in egit than it does in, say, subclipse or mercurialeclipse or the cvs team plugin.
Re: check in/out problem [message #754102 is a reply to message #750389] Mon, 31 October 2011 14:47 Go to previous messageGo to next message
Bit2_Gosu  is currently offline Bit2_Gosu
Messages: 6
Registered: October 2011
Junior Member
ok, i used svn before, where I only used synchronisation view actually.
Thanks!
Re: check in/out problem [message #754212 is a reply to message #754102] Tue, 01 November 2011 08:49 Go to previous message
R Shapiro is currently offline R Shapiro
Messages: 378
Registered: June 2011
Senior Member
In my experience there are two main reasons to use the Synchronization perspective in Subclipse. One is to review local changes before committing them, the other is to review incoming changes. For anything else it's more efficient to run the SVN operations from your primary development perspective (Java, C++, whatever). I've watched a number of developers switch to the Synchronization perspective just to do a blind svn update or commit, without any kind of review. I have no idea why they do this, I'm guessing they were taught to do it that way and never looked further.


To review before committing in egit, I strongly recommend the 'Git Staging' view.

To review incoming changes (ie, fetched or pulled) you can get at the incoming commits from the modal popup that appears when the egit operation completes, and open any given commit in its own window for more details. Might be nicer if this commit list weren't modal -- this was discussed in another thread. But it works ok as it is.

You should also ensure that the 'Git' command group is enabled in your primary perspective. This will give you menubar and/or toolbar support for all the fundamental operations: Add, Commit, Checkout, Rebase, Reset, Push, Pull, Fetch,

That doesn't leave much for the Synchronization perspective except branch/reference comparisons. In small repositories this works pretty well. For large ones, or any size repo with a very long history, it's pretty slow.

A feature I'd really like to see in egit is the equivalent of 'git log B1 ^B2', that is, a list of commits in one branch/reference but not another. This is generally a very fast operation on closely related branches and is extremely useful. If I could get the result as a view containing a list of commits, somewhat like the 'Git Reflog' view, that would be a huge win.
Previous Topic:rebase fails
Next Topic:Maven Repository not available
Goto Forum:
  


Current Time: Sun Apr 20 09:39:50 EDT 2014

Powered by FUDForum. Page generated in 0.01736 seconds