You are currently browsing the tag archive for the ‘git’ tag.
This how I took an existing directory of files on my desktop and put it into a new git repository on a remote server. I found a number of how-tos online but none worked for me – certainly this was because I’m such a newbie with git that I wasn’t sufficiently understanding what I was being told to do. The following works for me; clearly this isn’t the only way or the best way to accomplish the task. This is mostly a note to self.
Create an empty directory on the remote server to hold the repository
$ mkdir -p /var/local/git/repos/CrashTesting
Intialize the empty repository
$ git --bare init
Initialized empty Git repository in /var/local/git/repos/CrashTesting/
Now I have the necessary repository components.
$ ls
branches config description HEAD hooks info objects refs
On my desktop, in the existing directory of files, init the directory
$ git init
Initialized empty Git repository in /Users/crashing/Desktop/testws/.git/
This created a .git
directory with git control files.
Next, I tell my local desktop repository about the remote repo. The remote repo is given the short name origin
.
$ git remote add origin ssh://server.crashingdaily.com/var/local/git/repos/CrashTesting
Then, I place my local files under version control.
$ git add .
Now I can commit the local files to the local repository.
$ git commit -a -m 'initialize repo'
[master (root-commit) 7871087] initialize repo
23 files changed, 500 insertions(+), 0 deletions(-)
create mode 100755 build.properties
create mode 100755 build.xml
Finally, push the master
branch to the remote repository named origin
.
$ git push origin master
Counting objects: 44, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (44/44), 1.65 MiB, done.
Total 44 (delta 1), reused 0 (delta 0)
To ssh://server.crashingdaily.com/var/local/git/repos/CrashTesting
* [new branch] master -> master