Thursday, January 21, 2016

How to add/remove a Repository, Directory & File in GitHub


INTRODUCTION

  • Github is the web-based version control system.
  • A user can maintain public(free) or private(paid) repositories.
  • It also offers wikis, bug tracking, and management features.
In this article, we are going to learn
  1. How to do initial Github setup in windows
  2. How to add projects
  3. How to add new files to the existing project.
Make sure you have installed Github into your machine.

INITIAL SETUP

  1. Login to https://github.com and signup with your own username and password.
  2. Create a new repository (e.g: testupload)
  3. Create a new folder on your computer (windows) - "testupload" under c: drive
    1. Create any file (e.g: test.txt) with some content (e.g: this is a test text file)
  4. Open GitBash Application and go to the location c:\testupload
  5. Enter command: git init
    1. If success, .git folder will be created under c:\testupload
  6. Enter below command to add file(s):
    1. Command to add single file: git add test.txt
    2. Command to add all files: git add .
  7. Enter below command to commit the file
git commit -m "test file added"
  1. Enter below command to push the file into online Repository.
    1. Command: git remote add origin  https://github.com/javabyranjith/testupload.git
    2. Command: git push -u origin master
    3. Enter your github username
    4. Enter your github password
  2. Now check the online repository

ADD MORE FILES

  1. Add a file (HelloWorld.java) into the local folder c:\testupload
  2. Enter below commands
    1. > git add .
    2. > git commit -m "Hello world java file added"
    3. > git push
    4. > Enter your github username
    5. > Enter your github password

REMOVE FILES/FOLDER

  1. > git rm -r --cached <DirectoryName/File>
  2. > git commit -m "Removed Directory"
  3. > git push origin master
  4. > Enter username
  5. > Enter password