(Day 42 of 100) GitHub

Dongyob (Eric)
2 min readMar 8, 2019

--

Topics Covered: commit, deploy and update changes on GitHub

0. Links

  1. Commit on GitHub
  • Create GitHub account
  • Create new repository on the website
  • To commit the app on GitHub, run below commands on the terminal at the local file location where the app lives (Note: you should have git installed on your local machine)
#Initialize git
$ git init
#add all changed file paths to staged changes
$ git add .
#commit all staged changes
$ git commit -m 'initial commit'
#add remote repository
$ git remote add origin https://github.com/dyl4810/recursiveTreeviewExample
#push local repository to remote repository on GitHub
$ git push origin master

2. Deploy create-react-app + redux on GitHub

  • To deploy the app on GitHub, modify package.json file and run commands as illustrated below.
add the codes on the red box. The “hompage” specifies the host path where you want to host the application. The URL that works with GitHUb is: https://[your-user-name].github.io/[your-repo-name]/ “predeploy” specifies the command to build before deployment. “deploy” specifies which branch and directory to deploy
#install gh-pages package
$ npm install --save gh-pages
#build ?? what does this do exactly ??
$ npm run build
#deploy application
$ npm run deploy
#After the deployment, a second "gh-pages" branch is created on the repository which contains the static code (code that does not interact with server-side is what I understood)

3. Update changes on GitHub

  • Update is very similar to commit. See below
#Initialize git
$ git init
#add all changed file paths to staged changes
$ git add .
#commit all staged changes
$ git commit -m 'what ever your comment goes here'
#push local repository to remote repository on GitHub
$ git push origin master

4. Change repository

  • To change repository, you need to first remove already assigned repository from your app, then reassign to the new repository. See below.
#Check assigned repository
$ git remote -v
origin https://github.com/dyl4810/recursiveTreeviewExample (fetch)
origin https://github.com/dyl4810/recursiveTreeviewExample (push)
#Remove Remote
$ git remote rm origin
$ git remote -v
#Add new repository
$ git remote add origin https://github.com/dyl4810/dynamicDataTable

5. Ignore some files and folders

#you can achieve this by setting up .gitingore on the root path of 
#your project and write files you wish to ignore.
#Helpful tip: gitignore.io gives default list of things you should
#ignore in any framework.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response