Synchronizing copied repository with GIT repository - eclipse

I have copied repository from my team member and I want to synchronize with GIT repository.
Please keep in mind that I am new to GIT and I only have URLs of the repository where I need to synchronize. I need help to connect my repository with GIT repository. I have not imported any repository and I have just copied that. I will be able to push or pull or merge etc. only if my project is synchronized with remote repository. Please let me know that how can I synchronize. Thanks

It's unclear from your question whether you are trying to simply keep two copies of the same repository synchronized or something else.
If it's the first, then what you want to do it a git clone. Your changes should be git commit, to get remote changes you should git pull and to push your changes to your co-worker's repository, you should git push.
Depending on your operating system, there are different front-ends for Git. I gave you the command-line version. I saw you tagged your questions with the eclipse tag, which suggests you are trying to do this inside Eclipse. In that case, you might find EGit useful. See the EGit User Guide here.
If all this sounds too complex for you, you should first Read The Manual - that is, check out the Getting Started chapter of the Git Documentation.

I found the solution. I had to go in team-> share projects. then "create a new repository location" and paste the url of git repository. then team->share project-> git and add the repository. Now my copied repository is linked/connected with my git repository and I am able to synchronize my repository.

Related

How to clone a project and stay tuned with new updates

I want to clone POX Controller from Github repository into my laptop. The only way I know is by cloning. However, I think if someone clone a project, he/she won't get the updates that the others have done in it. I have read about forking but I don't really understand the difference between fork and clone. So how do I get a project from Github and still be able to receive updates?
Thank you.
To clone a repository means that you will download the whole code of the repository to your laptop.
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea. More at Fork A Repo.
as #TimBiegeleisen says, you can get the project and stay updated by clone once then git fetch it periodically.
For example, if you want to cloning POX Controller, clone it:
git clone https://github.com/noxrepo/pox
Then to update it, do the following command on your cloned project:
cd pox // go to your clone project
git fetch
Or you can use git pull instead of git fetch if only need to stay update without keeping your change in the cloned project.
But you must remember the difference between git fetch and git pull. #GregHewgill answers explain it in details:
In the simplest terms, git pull does a git fetch followed by a git merge.
You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/. This operation never changes any of your own local branches under refs/heads, and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn't recommend doing this).
A git pull is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.
Git documentation: git pull

Merging git hub repository with perforce depot

I have project A. The project A is in perforce as well as in github( Business decision). They are both out of sync. I see that I can use git-p4 tool http://git-scm.com/docs/git-p4 to submit git changes to perforce. Problem is first instruction of it says is:
git p4 clone //depot/path/project
This command will create a new repo in git hub. I do not want that. I want my existing perforce depot to connect to exiting github repo and then sync files from github to perforce. Is it possible?
No. git p4 is basically just a wrapper around Perforce. It reads changes to a Git repo and issues the proper Perforce commands to commit them (and vice-versa -- it reads changes to a Perforce checkout and issues the proper Git commands to update a Git repo accordingly). So you need to have a Perforce checkout and a local Git repo that can talk to that Perforce checkout.
Fundamentally you have two different histories for the same project, so you need to find some way to reconcile them.
git-p4 can sync from Perforce (create a new git repository), then you can add a new remote pointing to github, and sync the branches from there.
However that doesn't help with the problem of merging the histories.
You can either:
Go with Perforce, and rewrite github history
Go with Github history, and get your perforce admin/Perforce (company) to rewrite your Perforce history.
2 is probably (politically) impossible. May be impossible technically. Perforce is designed to prevent history from being altered.
1 will break anyone cloned from your github repository.
You may want to take a look at Git Fusion, which is a bridge between Git and Perforce:
http://www.perforce.com/git-fusion
This KB article gives an example of how you may wish to work with a project that is both in Perforce and a public Git repo:
http://answers.perforce.com/articles/KB/7481/
Hope this helps!

EGit Local vs. Remote repositories

I'm new to git and am wrapping my head around how I'm supposed to be using git and egit. From the egit tutorial, I have setup a respository on GitHub, pushed my Eclipse projects to the remote GitHub repository from my local workspace, I can push changes to GitHub, switch branches, see the updates on GitHub, etc. This all makes sense.
Looking at the Git Repository explorer, I have a listing of "Local" branches and have no "Remote Tracking" branches and I have no "Remotes" listed. When I create a branch from a local branch, the egit dialog indicates "You are creating a branch based on a local branch" and suggests that I should be making a branch from a remote tracking branch.
So my question is, am I correctly using egit?
Should I just continue pushing changes to the remote GitHub repository? If so, what happens once I share the project and other developers clone the repository and start making changes to the remote repository?
Or should I now ditch the local repository and setup a new remote repository by cloning the existing GitHub repository that I initially created from my workspace?
Or do I create a new Push and Fetch "Remote" for my existing git repository?
Or something else?
Confused.
Since you created the repo on your local system and then pushed it to github without creating a remote you don't have a remote at hand. A remote is simply a short alias for the remote repository's URL. To fix this create a remote and a push and fetch configuration from the repositories view. In order to populate remote tracking branches in your local repo you need to run fetch once. As soon as this is done you can use "Push to upstream" instead of the more complex Team > Push... dialog which allows to define all parameters on the fly. When using native git command line you'll find the same concepts implemented there:
with
"$ git push [url] [refspec]" (e.g. "$ git push https://github/user/myrepo.git master:master")
you pass all parameters explicitly, this is similar to Team > Push... in EGit
with
"$ git push [remote]" (e.g. "$ git push origin")
you push to the repository defined by the configuration parameters of the given remote (check .git/config to see these parameters or open repository configuration from egit preference in Eclipse), this is similar to Team > Push to upstream in EGit. Usually the refspec used in this way is implicitly configured when creating a local branch based on a remote tracking branch. It's also possible to add this configuration later but since this is more
tedious manual configuration the other way is more handy.
If you clone a remote repository the repository you cloned from is stored as remote "origin" in your clone. This way you can skip configuring the remote manually. This is only needed if the repository is born when you create it from scratch.
The "Branching" section of the Egit User Guide can help:
There is no obligation to create a local branch which would be named like a remote tracking branch (see "Having a hard time understanding git-fetch" to have a good understanding of "remote tracing branches).
You can create as many local branches (i.e. branches that you won't necessary push anywhere) as you want/need.
But if you don"t see any remote branch, maybe you didn't fetch that GitHub repo in the first place: see Fetching.

How do I get MercurialEclipse and Bitbucket to talk to each other?

I'm an Eclipse user, but I'm a newbie to Mercurial and to Bitbucket. I think I understand the command-line hg commands. I can create repositories, clone, push, pull, update, that stuff.
If I have a project in Eclipse, I can create a local repository for it. I can't figure out how to clone this repository up to Bitbucket.
If I have a project in Eclipse, I can create a remote repository on Bitbucket. Then I don't have a local repository, so I can't use any of the Team... commands, and can't do anything.
If I have a repository on Bitbucket, I can't get to it, because I don't have a local repository, so again I can't do anything.
If I create separate repositories locally and on Bitbucket, then I have two different repositories, and I don't know enough Mercurial to merge(?) different repositories.
There must be some blindingly obvious to get a project off the ground, but I'm blind to it. I can do this just fine from the command line, but MercurialEclipse is defeating me. No luck so far with Google and assorted documentation...
Help?
Doing it using Eclise "Team" UI:
Create a project in Eclipse and "share" it using Mercurial repository type. That will create local repository (by default in the same location where your project is).
Create project repository on BitBucket.
Use "Team">"Push" to push local changes to your remote BitBucket repo. First time it will ask you to enter the repository URL, user name and password. All this information is available on your Bitbucket web UI.
Don't forget that you have to do 2 stage commits after that. Commit in Eclipse UI will commit it in your local repository. In your team perspective's Synchronize view you will see additional "Outgoing" and "Incoming" entries. Using right-click menu on them you will be able to push/pull your changes to/from your BitBucket repo.
Remote repo information can be managed in special "Mercurial Repositories" view.
More info can be found in the tutorials at http://ekkescorner.wordpress.com/blog-series/git-mercurial/
Following the directions provided by bitbucket should be enough.
You can either create a repository on bitbucket and clone it on your desktop:
hg clone https://bitbucket.org/youraccount/yourproject
...
hg pull -u # to pull changes and update
hg push # to push changes to this repo
Or use a local repository and push these changes to a newly created repository on bitbucket:
cd /path/to/existing/hg/repo/
hg add [...]
hg commit
hg push https://bitbucket.org/youraccount/yourproject
Basically, two repositories are "bound" by:
a common changeset in their history
the [paths] configuration in /path/to/existing/hg/repo/.hg/hgrc, that lists remote repositories you can read/push to.

Git/Mercurial locally ontop of local cvs checkout

I have read :
"Best practices for using git with CVS"
"How to export revision history from mercurial or git to cvs?"
, and neither suit my needs.
At work we use a remote CVS repo. Access to this repo is handled via eclipse CVS tools, and in-house eclipse plugins that are built ontop of team tools for eclipse. This means we can't move to a better vcs.
However I would like to use Git on my local machine (to enable personal branching) such that I can accomplish the following:
Create branches in Git and then once finished and merged back into my local trunk, commit back to the cvs repo using the eclipse team tools etc.
My plan is something along the following lines:
Copy the checked out files to another folder [gitRepo].
Create a master git repo in gitRepo
Branch in gitRepo and make changes.
Commit to gitRepo
Copy gitRepo back to checked out files
Sync with remote cvs.
I was planning on using eGit for eclipse however I believe that the CVS and .git files will compete for ownership of the versioning.
Are there any tools or suggested work flows to help me manage this? Also how well does Git play with CVS files. And vice versa since I don’t want them to infect each other.
The reason the former links are of no use is they commit straight to the cvs repo from the git repo and this worries me as I do not wish to infect the cvs repo by accident.
It should also be said that changes in the GitRepo do not need to persist into the CVS repo, for example I don’t need to see every push to the git repo reflected in the remote CVS.
~Thanks for reading.
You perfectly can create a git repo directly within a CVS workspace (much like directly within any other VCS tool.
Make sure git will ignore any .cvs resources, and make sure CVS will ignore the .git.
Any Git commit won't be directly reflected in CVS.
The only trick is for Eclipse to display only Git or only CVS informations and label decoration.
For that I would configure two different Eclipse perspectives in which I will de-activate one or the other VCS tool.
I have done exactly this at work and I found the following practices helpful:
Keep any one (master in my case) branch always in sync with CVS. Do not use this branch for your development. Periodically update this branch to get the changes made by the rest of the team. If these changes are relevant to your current work do a merge master from your dev (or any other appropriate) branch.
When you are ready to check in to CVS switch to the master branch and merge the changes from the appropriate branch (dev, feature etc. as appropriate). Run your tests!
You employer most likely will keep a back up of the CVS repos. You will have to find a way to keep your git repo backed up. One way is to add a mirror repository in a Dropbox folder and use a post-commit hook to update it after each commit.
Before you leave work switch to the master branch. I once made the mistake of running CVS up -d on a dev branch in the morning and ended up quite confused. Adding a script to automatically switch to master before updating helps.