Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Idenifying a repository(Telling to which remote repository a certain .git direktory belongs)
Idenifying a repository [message #647947] Mon, 10 January 2011 15:04 Go to next message
geX is currently offline geXFriend
Messages: 6
Registered: July 2010
Junior Member

I want to write a program that works on top of EGit/JGit. I have one problem: Given a list of remote repositories (these repos may be specified by some unique information) and a local .git repository, I want to be able to tell to which remote repository of this list the local repository belongs.

"Belongs" means created by pulling from that remote repository in this context. Of course, a local may belong to more than one remote repository, but in my scenario, this is not the case.

Is there any way to identify a remote repository such that I can quickly (without repulling the remote repo) tell, if a local repository corresponds to that remote one. This is not security relevant, so the used concept does not have to work in the case when someone maliciously deletes information from the local repository.

I thought about identifying remotes by a random key and then just adding this key to the config file. However, I think the config is rather local and is not copied from a remote repo. Is this true?

Another idea was just recording the SHA of the first commit in the remote repo and using this as the key saved in the list of remote repos. Then I could just check if the local repository has this commit.

Do you have a good solution for identifying local repositories?
Re: Idenifying a repository [message #648087 is a reply to message #647947] Tue, 11 January 2011 08:15 Go to previous message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 274
Registered: July 2009
Senior Member
The configuration (the .git/config file) of your local repo may contain the info you need. If a local branch have been setup from a remote repo's branch then this will be stored in the config. E.g. if you clone a remote repo your local branch "master" is connected to the remote repo by the config params "branch.master.merge" and "branch.master.remote". If branch.master.remote is equal to "origin" then remote.origin.url will tell you about the conrecte URL of that repo.
Same is true if you create a local branch which starts of from a remote tracking branch.

Previous Topic:One repository per Eclipse project?
Next Topic:Register ssh host?
Goto Forum:

Current Time: Sat Oct 01 22:11:20 GMT 2022

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

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

Back to the top