Sunday 26 May 2013

Creating a git repository in an existing directory with files

Git is pretty smart and will let you very easily hook up existing source code to a new repository without making you go through some awkward copy and paste process.

all you have to do is navigate to your directory with the source files and type:

git init

then you need to tell git which repository to hook it up to:

git remote add origin [repository url]

lastly you want to add an upstream so it knows which branch to hook the code to. you can always commit on the fly to any given branch, however, you may want to set your upstream for convenience and you can do it all in one go when you do your first push like this (this example sets the master branch as the default upstream):

git push --set-upstream origin master

all done! gotta love git.

No comments:

Post a Comment