Working with Git, Svn and Eclipse Together - eclipse

I am trying to find the right way to do this. My firm is using SVN as we are working on the projects to do checkin and checkouts. But I am thinking about using Git to backup all my work as I got home.. here is why
From Home I don't have access to my firms SVN Repo so I was thinking about setting up a Git Repo on the internet to checkin all my work into git before I leave work so I can access it from home.
I would like to hear if others are doing this and if you think this is a good practice.
How would I do this? I been using SVN and Eclipse for sometime now but I hear GIT would be better for cloning my workstation...

The solution to this for many people is 'git svn'. It allows you to create a local git repo as a clone of a tree in svn, work locally, and commit your work back to svn.
You can run git svn while at work, copy the resulting repo to a disk you carry home, and then commit back to svn when you get back to work. Always assuming, of course, that your employer's policies permit this. If you can't get to svn from home, perhaps they don't like anything about this idea.

Related

Synchronizing copied repository with GIT repository

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.

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!

Stopped Using Git - Now Want to Start Again. How to Get Synced Back Up?

We had a number of developers working on a large website project using Git. We have a GitHub repository and then we have the website on the server, plus all the developers have their local versions.
When we finally launched the project, I got lazy (hangs head in shame) and started making changes directly to the server, without pushing them back to the Github repo. However, other people made changes to the repo, for reasons I don't quite understand, that were never pushed down to the server and are now either outdated or wrong. We have been doing this for almost seven months.
Now the server and repo are hopelessly out of sync. I would now like to get the most updated version of the site (which is the server) back up to the Git repository so we can begin another round of development. I basically want to start with a fresh copy of what is on the server.
How would you recommend I proceed? That was the first time I had used Git. It didn't seem like such a big deal at the time but now seems like it is harder to start up again than I thought.
I have looked for instructions and don't really see anything that fits. Because I am not super confident in my Git skills, I am afraid to just start trying the few ideas I did find and losing what I have on the server.
(I know I could restore from a backup if I really messed it up but would prefer not to do that as it would take the site down.)
Can I uninstall git and start again with a fresh repo? Or is there a safe way to push the current version up to the repo?
Thanks for your help.
UPDATE: I found this answer elsewhere (Replace GitHub repo while preserving issues, wiki, etc) but I am not sure how to do this:
cd into "new" repository
git remote add origin git#github.com:myusername/myrepository (replacing myusername & myrepository accordingly)
git push --force origin master
Possibly delete other remote branches and push new ones.
Not sure what they mean by "new repository"
Make a new branch and push it to GH.
Make a new branch based on the previous
branch.
Switch to the new branch (created on #2).
Delete all the files and folders on this branch repository
except the .git folder and contains
(maintain the README.md,
.gitignore and other files if you want it).
Copy all the files from the server except
.git folder.
Commit.
Switch to local Master (created on #1)
Merge this new branch with the previous one.
Solve conflicts
(I use SmartGITthat have a visual conflict solver and helps me a lot, but you can use gitdiffif you don't want a visual interface)
Commit
Push it to GH.
I hope this helps
I figured this out. What I did was:
Make a new branch on Github to effectively store a backup.
$ git add . to stage all changes
$ git commit -m "Commit message" to commit changes
$ git push --force origin master to force changes from server to remote branch master
Once I did this, there were still hundreds of files I had deleted on the server that were not reflected on the remote github.com repository. I used the following:
$ git rm $(git ls-files --deleted)
See Removing multiple files from a Git repo that have already been deleted from disk
Then repeated git commit and git push. Now my github repo matches my server exactly.
I have not yet deleted the "backup" branch I created on github but I will.
Hope that helps someone.

manage git clone on remote server with eclipse

I'm new to git and github and I have a question about the git plugin for eclipse Egit.
I have made a clone from my github repository to a remote server (other than github) which I will call 'rserver' for the ease. Now I am editing the files in my repository on 'rserver' locally from my computer with eclipse (and the RSE plugin) but when I want to do any git actions like committing the changes I made, I do that directly on the 'rserver' (command line). Now I would like to be able to commit changes etc. with eclipse and (what I presume to be the best option) the egit plugin. Since all code needs to remain on the 'rserver' to be functional as a program, there is no point of making another local clone of my github repository. But all options I've tried with egit seem to do exactly that.
Is it possible to manage all git actions between 'rserver' and github from my local Eclipse SDK (other then using the terminal in eclipse)? And if so, then how?
git clones repos, meaning they contain the same objects.
I don't think there's a way to work on a remote repo, but you should git clone your rserver repository locally, work and commit there (this using eclipse), and when you want to upload your code to rserver or github, you just push your changes there.
When you git push, you make the remote branch point to the same commit your local branch points, uploading any remote-missing object.
Probably you will want to add both remote repostiories (rserver and github) as remotes of your local repository, so then you can decide to whether of both to push changes to.
There is much value in being able to edit files remotely and there is much value in being able to version control your files in git. Currently I have the same situation. My "rserver" however, is a Puppet master. I'm editing the files through RSE on the Puppet master with my local PC in Eclipse. There's a lot of value in editing the files directly on the Puppet master, trying out the change and if it doesn't work continuing to modify the files. Having to then ssh into the server just to do git actions is dumb. Having a local git clone that you have to git add, commit, push, then go to the server and git pull is even more dumb. Eclipse should allow you to do git actions through RSE.

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.