Blog is moving

My blog is moving to http://victormendonca.com/blog/. If you are looking for a specific or older post you are in the right place Otherwise check out my new page for more up to date content.

Monday, November 3, 2014

How to Add an Existing Folder on Your Computer to a New Git Repo

This is a simple and quick tutorial on how to add an existing folder (and files) on your computer to a new git repo.
1- Create your project online (like Bitbucket or GitHub)
2- Then cd into the folder where your files are and initialize it
$ git init
Initialized empty Git repository in /home/victor/Sync/BitTorrentSync/victor/www/.git/
3- Add all your files to be tracked (if you have anything that you want to exclude, you might want to do that with .gitignore now)
$ git add *
4- Commit with a initial message
$ git commit -m "My initial commit"
[master (root-commit) 652fc1a] My initial commit
 1942 files changed, 41072 insertions(+)
 create mode 100644 Arri/ARRICAM Checklist Project/ARRICAM ST CHECKLIST.doc
 create mode 100644 Arri/ARRICAM Checklist Project/k4.44256.0.jpg
 create mode 100644 Arri/ARRICAM Checklist Project/k5.42387.0.jpg
 create mode 100644 Arri/ARRICAM Checklist Project/k5.42388.0.jpg
...
 create mode 100644 wazem.org/sub.sites/Koken/photo.spheres
 create mode 100644 wazem.org/sub.sites/Koken_Installer.zip
 create mode 100644 wazem.org/sub.sites/Koken_Installer/koken/index.php
5- Add the remote location (example below is for Bitbucket)
$ git remote add origin git@bitbucket.org:[user]/[my-repo].git
6- Push the files
$ git push -u origin master
Counting objects: 2054, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2035/2035), done.
Writing objects:   1% (41/2054), 4.41 MiB | 844.00 KiB/s
You should see the following when it’s done
Total 2054 (delta 219), reused 0 (delta 0)
To git@bitbucket.org:[user]/[my-repo].git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

No comments: