GIT - Add repository to folder which have content

Hi all, its been sometime since I updated my blog. 
This time I encounter some issue with git. I start my project before I creating the repository ( which should be the other way round ).
After several search from internet and do some try and error, I figure out it is quite simple.
Start your Git Bash application and do the following:

# cd <code location>
# git init
# git add .
# git commit -m "my message"
# git remote add origin <git url>
# git push -u origin master

TADA! And your folder now is link with your git repository.
So what the above did?

1. git init : Initialize the folder as git directory
2. git add . : Add all files within the folder, including subfolders and their files
3. git commit -m "my message": Commit the staged code and give a comment of the commit as "My Message"
4. git remote add origin <git url>: Add the git repository url as remote url
5. git push -u origin master: Push code from local branch master -> remote branch master and keep this relation(by specifying -u which is setting the upstream)

Hope this small tips beneficial to you.

Thanks and have a nice day!

Comments

Popular posts from this blog

Django Form: MultipleChoiceField and How To Have Choices From Model Example

Jquery Validation fix for date format dd/mm/yyyy in Chrome and Safari

DJango Queryset comparing date time