Using Git like CVS
Using Git like CVS
Join the DZone community and get the full member experience.Join For Free
[Latest Guide] Ship faster because you know more, not because you are rushing. Get actionable insights from 7 million commits and 85,000+ software engineers, to increase your team's velocity. Brought to you in partnership with GitPrime.
Tonight I moved the http://rainbowcinemas.ca sources from phpeclipse and CVS to PDT and Git.
Below are some gotchas and tips for initial repo creation, how to keep the central remote copy up to date, and how to work around complaints about updating master directly from remote. I'm sure there's a better way to do this w/o the need for the workaround, but this is what I found worked.
To crawl a directory and create a git project for each subfolder:
for d in $(find . -maxdepth 1 -type d -not -name "." | \
egrep -v ".ssh|logs|OLD|download|upload"); do cd $d; \
git init; git add .; git commit -m "initial commit" .; \
cd ..; \
See also Setting up a shared repository.
Create local clone via commandline
git clone ssh://servername/path/to/.git folderToCreateLocally
Create local clone w/ eGit
Once your repo is created, you can clone a copy from the remote server onto your local box, and import it into Eclipse (with eGit installed) using File > Import > Git > Projects from Git > Clone... .
Commit local changes via commandline
As outlined before, you can git pull, git checkout, git commit, and finally git push your changes.
If you encounter an error trying to commit changes back to the repo, see the section below, "Allow a ref update to the currently checked out branch of a non-bare repository".
Commit local changes w/ eGit
With eGit, you can pull, push, checkout, commit, merge, etc. using the context menu on a Git project or with the Synchronize view. I don't recommend using any of the change sets / models except the Git Change Set, since the others will tend to show more than is actually needed (like local changes which Git doesn't track).
Allow a ref update to the currently checked out branch of a non-bare repositoryUpdate the ~/.gitconfig file on the remote server to look something like this:
name = Your Name
email = email@example.com
branch = auto
diff = auto
interactive = auto
status = auto
editor = vim
tool = vimdiff
denyCurrentBranch = warn
Retrieve changes into remote repo
Because I'm using the remote server to both host http-accessible files AND host the git repo, it's important that changes checked into the git repo be then checked out into the local filesystem so that the local workspace is in synch with the repo's metadata.
To pull changes, I use git status (to review changes), git reset HEAD <filename> (to reset specified file, or omit filename to reset all changes) and finally git checkout to retrieve the changed file from the repo into the working directory.
Access the server w/o a password prompt
To skip being prompted for a password when you connect over ssh, scp, or fish, add your public SSH key to the ~/.ssh/authorized_keys file on the remote server.
Access the server via an alias
Instead of having to reference the server as username@server when connecting, you can add an entry to your ~/.ssh/config file that looks like this:
Published at DZone with permission of Nick Boldt , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.