Last modified on 01 Oct 2021.
Things with Github.
View README.md localhost
pip install grip # https://github.com/joeyespo/grip
cd myrepo
grip # Running on http://localhost:6419/
Update: grip
support with limited times of usage, we can use VSCode markdown previwer instead.
Clone via git@ (ssh)
# On linux
ssh-keygen -t rsa -b 4096 -C "[email protected]"
# enter a file: /home/thi/.ssh/id_rsa
# enter password
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
# Go to https://github.com/settings/keys
# copy public key
cat ~/.ssh/id_rsa.pub
# clone
git clone [email protected]:dinhanhthi/dinhanhthi.com.git
Info
- Commits to a fork don’t appear in your contributions graph.
- Commits to a generated from template can appear in your contributions graph.
Repo template
I wanna make a theme notetheme2
based on dinhanhthi.com.
- Make
dinhanhthi.com
be a template (Go to Settings) - Create a new repo based on this template.
- Create a new branch
notetheme2
ondinhanhthi.com
. Make changes on this branch. - Everything we have a “theme change” on
dinhanhthi.com/master
, merge it to branchdinhanhthi.com/notetheme2
. - If there are files (only for files) in
dinhanhthi.com/notetheme2
you wanna keep, add below line to.gitattributes
(under branchdinhanhthi.com/notetheme2
) before performing the merge,# add line to .gitattributes echo 'file_name.txt merge=ours' >> .gitattributes # on windows, remove `''`
- If there are folders (or files) in
dinhanhthi.com/notetheme2
you don’t wanna keep (from/master
), just delete them and make a new commit. From this time, later merges will ignore them. - If there are folders in
/notethem2
you wanna keep the current state (instead of merging from master), create a scriptreset_folders.sh
#!/bin/sh # used for branch notetheme2 only echo 'Reset some only-this-branch folders after merging.' git reset folder_1 folder_2 git checkout . git add . git commit -m "update from master"
Each time you run the merge, run
git merge master && sh reset_folders.sh
- Update changes from
dinhanhthi.com/notetheme2
to reponotetheme2
[ref] .# add dinhanhthi.com as a remote git remote add template [URL of the template repo]
# update the changes git fetch --all
# update from template's branch git merge template/notetheme2
- If there is an error
fatal: refusing to merge unrelated histories
, try to add--allow-unrelated-histories
. There must be conflict.# keep remotes git merge -X theirs template/notetheme2 --allow-unrelated-histories # keep local git merge -X ours template/notetheme2 --allow-unrelated-histories
Add Shields tags
👉 Main shield site here.
👉 Example of usage: my main github page.
# scikit-learn badge
http://img.shields.io/badge/-Scikit%20Learn-efa300?style=flat-square&logo=scikit-learn&logoColor=fff
# ...<NAME>-<Background-Color>?style...&logo=<LOGO>&logoColor=<LOGO-COLOR>
- Logo name can be found at simpleicon. If the name includes spaces, replace them with dashes (e.g:
?logo=visual-studio-code
) - Wanna create a custom logo?
Errors
fatal: Authentication failed for
: It’s because you enabled two-factor authentication in your Github account.
- Generate a new token: click here.
- Copy that token and use it as a new password.
ssh: connect to host github.com port 22: No route to host
fatal: Could not read from remote repository
# solution
nano ~/.ssh/config
# add following
Host github.com
Hostname ssh.github.com
Port 443
# run again to check
ssh -T [email protected]