Git can do this, but it may be a little slow going until you read a few pages of docs. One concept that I had to understand was that every git project directory is a repository with a history of changes. Subversion only keeps revisions on the server.
To create your a primary git repository and another directory in your main dir:
- First make a bare git repository
Create a directory to store this project. I used /srv/git/yourappname - cd /srv/git/yourappname and run git init --bare
This is important and it will act only as a repository. In other words without the --bare flag, a repository is created with the expectation that source files will be in this directory and will be editted. - Go to your workspace directory and import, or in git terminology - clone the project
cd ~/workspace
git clone /srv/git/yourappname myapp
- cd ~/workspace/myapp
- Edit some files
- git add .
(do this in myapp) - git commit -a -m 'my commit'
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '/srv/git/yourappname'
Reading some of the docs, one would expect you would only need to type in git push to do this. The first time you need to do:
- git push origin master
What this does is create the the master branch on the origin repository. I supposed this is like creating the trunk in svn. - Subsequent pushes only require git push to update your code on master.
- Even if you delete ~/workspace/myapp and do another clone, you will again only need to do git push
Getting this to work with Eclipse
If you're using linux, there are a few gui's available gitg, gitk, git gui (That's the command 'git gui'). Some of us use eclipse as our primary ide, so it's convenient to have git integrated with our workflow. Here's how to set it up. Sorry I'm too lazy for screenshots. I'm using Eclipse Helios SR-1
- Make sure you have the git plugin.
- If you did the above steps you can add that git project to the Git Repository Interface.
- Select 'Add an existing repository to this view'
- Select /home/you/workspace/myapp
- The repository will appear in the interface, like a repository appears eclipse subclipse.
- Click on Working Directory and select 'Import Projects'
- Go through the wizard, select your project type and tada, that's all there is. You will now have a git managed project where you can commit your changes to. Like SVN, you go to TEAM and perform the operations tasks you want.
No comments:
Post a Comment