July 30, 2021
Heroku is a cloud platform as a service that supports multiple programming languages. One of the first cloud platforms, Heroku has been in development since June 2007, when it only supported the Ruby programming language, but now supports Java, Node.js, Scala, Clojure, Python, PHP, and Go.
# heroku | login
$ heroku login
# heroku | project cloning
$ heroku git:clone -a myapp
# create README.md (Documentation Git)
$ echo "# API" >> README.md
# prepare git repository
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin https://github.com/moeclay/api.git
$ git push -u origin master
Add Domain to Heroku
# add to dns management
<empty> or @ ALIAS or CNAME hidden-sierra-7936.herokudns.com.
# add to heroku
$ heroku domains:add example.com,
$ heroku domains:add www.example.com
Branching is used to develop isolated features. The main or master branch is the default branch when you create a repository. Use another branch for development, once done, merge back into the main branch.
# create a new branch with the name "feature_x" and switch to it
$ git checkout -b feature_x
# switch back to master
$ git checkout master
# delete the previously created branch
$ git branch -d feature_x
# a branch is not open to another unless you send it to the remote repository.
$ git push origin <branch>
Update & Merge repository:
# update local repository to latest commit
$ git pull
# merge other branches into active branch
$ git merge <branch>
# if there is a conflict, change the file pointed to by git and mark it
$ git add <filename>
# before merge takes effect, do a review
$ git diff <origin_branch> <destination_branch>
Marking Changes:
It is highly recommended to create tags or tags for the released software. 1b2e1d63ff are the first 10 characters of the commit identity that you want to reference to the marker.
# create tags
$ git tags 1.0.0 1b2e1d63ff
Change Logs:
# learn basic logs
$ git log
# add according to the desired parameters
# eg: author
$ git log --author=moeclay
# show compressed logs
$ git log --pretty=oneline
# all ascii branching trees with the name of the marker
$ git log --graph --oneline --decorate --all
# see changed files
$ git log --name-status
# advanced documentation
$ git log --help
Reverting Local Changes:
# if you make a mistake, can revert to the last content
$ git checkout -- <filename>
# back based on git encryption
$ git reset --hard fc3238fc0d847b6e27ae1c6351884f61f06fdacf
# completely abort local commits, retrieve server's recent history and point to local master branch
$ git fetch origin
$ git reset --hard origin/master
# remove git remote
$ git remote rm origin
# check git remote
$ git remote -v
$ git remote add origin https://github.com/moeclay/moeclay.github.io.git
# clear all commit old post
$ git push origin HEAD --force
Other useful commands:
# built-in git gui
$ gitk
# colorful git output
git config color.ui true
# show log one line per commit
$ git config format.pretty online
# using interactive addition
git add -i
author : doctor. moeclay