Personal tools
You are here: Home resources docs git Creating a local git repository for a new Eclipse Pydev project.

Creating a local git repository for a new Eclipse Pydev project.

Requirements

 

  • A properly installed and configured GIT installation
  • A fresh Pydev project in eclipse

Definitions

git-add
Add file contents to the index
git-init
Create an empty git repository or reinitialize an existing one
gitignore
Specifies intentionally untracked files to ignore

Initializing your new git repository

(Example using the OS X default Eclipse Workspace)

Here we set a variable for our Eclipse workspace, please adjust for your OS

LOCAL_GET_REPOSITORY=${HOME}/workspace

Variable for our Repository

REPOSITORY_DIR=Utilities

Make our repository directory if it does not exist

 

cd to our eclipse workspace
cd ${LOCAL_GET_REPOSITORY}/${REPOSITORY_DIR}
git init

Example Output

 

Initialized empty Git repository in /home/cjs/workspace/.git/

Or reinitialization output

Reinitialized existing Git repository in ${HOME}/Documents/workspace/.git/

Staging


After initializing a new git repository you will probably want to commit your project files to the repository.  Before you can do this you will need to "stage" your project files by adding them to the index. To add all the files in your current project directory to the index run the following command:

git add .

(Notice the space followed by  period after the git-add command!)

Committing

To commit your project run something like the following customized to your requirements:

git commit -m "Initial commit for chris's eclipse workspace projects"

Check the repository status

 

git status

 

Example Output

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   .metadata/.mylyn/.tasks.xml.zip
#       modified:   .metadata/.mylyn/tasks.xml.zip
#

Ignoring Files

In the above example output we have some mylyn stuff that we really don't need to backup
You will probably want to ensure than certain files don’t ever get committed to the repo:

Create a .gitignore file

touch ${LOCAL_GET_REPOSITORY}/.gitignore

Add some files to ignore

echo ".metadata/.mylyn/.tasks.xml.zip" >> ${LOCAL_GET_REPOSITORY}/.gitignore
echo ".metadata/.mylyn/tasks.xml.zip" >> ${LOCAL_GET_REPOSITORY}/.gitignore

See http://www.kernel.org/pub/software/scm/git/docs/gitignore.html for more info

Other Configuration Options


You can also enabled more colorful output with:

git config --global color.status auto 
git config --global color.branch auto

 

Document Actions