Skip to content

eugeneware/git-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

This is the script I wrote to automatically create a new git repository on an ssh server and then point my local git repository origin to it.

You'll need to copy it so that it's in your path (I put it in /usr/local/bin on my Mac)

You use it like this (assume you are working in a directory called mygit):

	$ git init .
	$ git add .
	$ git commit -a
	$ git deploy you@yourserver.com:~

The result is that your git repository will be copied to your SSH server (eg. you@yourserver.com:~/mygit.git in this example) , and will be set as the origin so that you can just do "git push" and "git pull" with no parameters and it will be applied against this new repository:

	$ git pull
	$ git push

If you put a third parameter:

	$ git deploy you@yourserver.com:~ backup

Then it will do the same, but not call the remote repository "origin" but will call it "backup" (in this example). 

This means you can easily add remotes, which is useful for backups. This means you'll need to do:

	$ git push backup
	$ git pull backup

UPDATE: 9-Dec-2008
Added a "-a" option thats adds an auto "git push" on every commit (sort of what svn does).

For example:

	$ git deploy -a you@yourserver.com:~
	$ echo "blah" >> test.txt
	$ git commit -a -m "This should auto push after commit"
	Counting objects: 5, done.
	Writing objects: 100% (3/3), 298 bytes, done.
	Total 3 (delta 0), reused 0 (delta 0)
	To you@yourserver.com:~/test.git
	   283643c..15536a4  master -> master
	Created commit 15536a4: This should auto push after commit
	 1 files changed, 1 insertions(+), 0 deletions(-)

So the very act of committing a file will run a "git push" after the commit. This is useful to keep the remote repository in sync (for team development or backup purposes).

This is implemented by putting a "git push" command in the .git/hooks/post-commit file

The default is that this hook ISN'T ADDED. So you need to add the -a to add this in

UPDATE: 19-Dec-2008
Fixed some bugs concerning pushing repositories with spaces in the file name

UPDATE: 27-Feb-2009
Made a change so that you can deploy to a server when the folder already exists (useful for shared git repositories where you need to give sudo privileges to create the folder)
Made the autocommit options work for the specified branch rather than just git push - which affects the origin only.

UPDATE: 25-Mar-2009
Arlen is a demon.

About

A shell script to easily push a local git repository to an ssh home and set it up so you can just "git push" and "git pull"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published