Revisioning your project using GITFrom WikiJava
versioning a project in GITThis is very simple, and it is described in so many places around the web that I won't be going too much in detail on this. What is important is to use this procedure as early as possible in your project, so that you start saving the history of your files very early and have complete history. You can use the next techniques only after you are already versioning your project, so, again, it's important to do this asap. This procedure will revision your project on site, so it won't require anything more than your project directory. No special servers or strange installations. (Ok Git works only on Unix like systems, so if you are a windows use you may need to install it via cygwin, but this is very easy as well]. Ok, let's start with the directions, from the very beginning. You just started writing your project, have just written the first test class, or maybe just used the maven archetype to get your starting project structure (check out the article Starting a Java project with Maven 2, to see how). You have your project on your disk, at some consistent state (ie. it builds, and the unit tests you created are successful), you need now to start versioning it. First step is to initialize the local repository. You do this with:
This will create a .git subdirectory containing the empty git repository, ready to store the versions of your project. Nothing is stored now. You will need to add them manually. Your project directory probably also contains some files you want to keep out of the repository, so that you don't remember their history. These are generally the files generated by the builds (target or bin directories, log files) but also the operating system files such as (files .DS_Store, Desktop.ini, Thumbs.db ... ). There's a very easy way in Git to exclude files or directories from versioning. Just: add their name to the .gitignore file. it accepts wildcards too. The commands are:
In the snippet below I show you how I did it. dongiulio@host:~]$cd my-project/ [dongiulio@host:~/my-project]$ls pom.xml src [dongiulio@host:~/my-project]$git init Initialized empty Git repository in /Users/dongiulio/my-project/.git/ [dongiulio@host:~/my-project]$git st # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # fileIdontWantToVersion.txt # pom.xml # src/ nothing added to commit but untracked files present (use "git add" to track) [dongiulio@host:~/my-project]$echo fileIdontWantToVersion.txt >> .gitignore [dongiulio@host:~/my-project]$git st # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # .gitignore # pom.xml # src/ nothing added to commit but untracked files present (use "git add" to track) [dongiulio@host:~/my-project]$git add .gitignore pom.xml src/ [dongiulio@host:~/my-project]$git st # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: .gitignore # new file: pom.xml # new file: src/main/java/org/wikijava/App.java # new file: src/test/java/org/wikijava/AppTest.java # [dongiulio@host:~/my-project]$git commit -m "first import" [master (root-commit) e21c962] first import 4 files changed, 77 insertions(+), 0 deletions(-) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/org/wikijava/App.java create mode 100644 src/test/java/org/wikijava/AppTest.java [dongiulio@host:~/my-project]$git st # On branch master nothing to commit (working directory clean) Sharing your git project to an SVN repositoryIn this paragraph I'll show you how to share your git repository to a svn server. This is something I use quite often, because many of the projects I contribute to are versioned on SVN, and I don't want to give up the benefits of GIT (especially the ability to use versioning even while I'm offline). This is very simple, these are the steps:
Publishing your repository on the webTo be completed... stay tuned... sorry.
|
