How to start developing fast using temporary git repositories

Very often I find myself working something on remote server, and wanting to have a remote .git repository of changes, but almost always I do not do it, because of the process of creating a new public key, adding it to the gitolite admin repository, ... A lot of steps.

Here is procedure on how to start .gitting as soon as possible, and once you have a 'free' time (usually near the end of the day), you can go through these steps in one sitting.

Important thing is to have it in .git as soon as possible. Thinking about permission, and public keys, we will left for later.

Here is the workflow.

User starts working on repository

cd project/
git init
git add -A .
git commit -m 'initial commit'
git push --set-upstream master

You can now start working with your own repository:

  • edit file(s)
  • git add file(s)
  • git commit -m 'message about the change'
  • git push
  • repeat

Admin can review what new repositories are created

ssh info test/

User can create new public key and start working privately on this repository

Give that user a key. A temporary key !

# IMPORTANT: use password!!!
cat ~/.ssh/
# TODO - How to easily send a .pub key ?

cp ~/.ssh/ .
git add
git status
git commit -m 'added .pub for current user'
git status
git push

Now, send the .pub key to the admin. If you follow steps above, you added .pub key to repository, and it will be available for admin.

Note: It is important that any temporary key have a password added to it. We will rotate these files, and do not want to have some key is there for someone else to use.

Admin, adding user's temporary key to the system

cd ~/git/gitolite/
cd keydir/nedzadhrnjica/temp/
git add
git commit -m 'added temporary key for server'
git push

Admin, rename repository from temporary one into permanent/regular one

Clone test repository into real-one:

git clone
git remote rename origin temp
git remote add origin
git config branch.master.remote origin
git push

Remove test repository:

ssh D unlock test/this/is/my/repository
ssh D rm test/this/is/my/repository

Additionally, you can create temporary repostiory with an information where the project is actually moved:

git clone
git commit --allow-empty -m 'Repository moved to :this/is/my/repository'
git push

# Finally, remove local repository, since we do not need it anymore
rm -fr repository/

This temporary repository will be left 'hanging' on the server, until all its users (actually only you) stop using it. You can easily remove it later on with steps listed previously.

User, update repository to the new one listed by admin

Once you sent the .pub key to admin, and admin added it to the repository, you can now replace user in .git/config:

sed -ie 's/gitanon/git/' .git/config

And, continue working on your project.

Additional notes

When doing with .git repositories, always have all of them kept in the same local subdirectory:


This way, you will always have a list of all your repositories at one place, so you can easily review them, work on them, and improve them.

If you have projects in any other directories, you can always link from there to the git project into this subdirectory.

Make it a habit.

Do not even create 'temporary' .git repositories anywhere else. If you want to test something, create repository in ~/git/test/name and link this subdir to the place you are working with.

# create test repository

git init ~/git/test/123
ln -s ~/git/test/123 123
cd 123/

# work on it
git add
git commit -m 'added'
git push

# finish testing, remove it
cd ..
rm 123/

# remote test repository,
# or do it later, if you have not time now, or want to get back to it later again
rm -fr ~/git/test/123/