Tuesday, March 1, 2016

Visual Studio Code: how to work with GitHub

Visual Studio Code (VSC)  is powerful editor for developer in web app project. I like to use it in my project relating to Angular. GitHub provides public git repositories for community.

Below are steps to help you work with your GitHub from your project on VSC:

1. Install git
+Download and install GIT from: http://git-scm.com/downloads
+If you use Windows, let set PATH environment includes the folder which GIT is installed
+Check if GIT works by the command: # git --version

2. Create an empty repository on your GitHub and get its URL. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub. For example my repository is: https://github.com/vnheros/ionic-test-FB-login

3. Use command line, go to your project folder. Configure your GIT global user & email (this step just is needed to do one time, you don't need to redo for later projects):
# git config --global user.email "your email"
# git config --global user.name "your name"

4. Open your project on VSC and initialize git repository for your project:

Or you can run the command:
# git init

5. Create a README.md and commit all files in the folder to your repository on GitHub, below is command lines for example:
# echo "blah blah about the project" >> README.md
# git add README.md
# git commit -m "first commit"
# git remote add origin https://github.com/vnheros/ionic-test-FB-login.git
# git push -u origin master


Note:
+You must replace my https://github.com/vnheros/ionic-test-FB-login.git by the URL of your repository. Don't forget suffix .git in the end of the URL.
+Last command will require you input username & password of your account on GitHub
+Use .gitignore file to skip folders which you don't want to submit to GitHub
+Use http://dillinger.io/ to edit & check your README.md, then copy & paste it to VSC

Now your project is binding with the repository on GitHub, you can use GIT function on VSC to add and commit any files when changing.

Happy codding! Welcome any comments!



No comments:

Post a Comment

Subscribe to RSS Feed Follow me on Twitter!