Remove Python pyc File

in python

Python interpreter在執行的時候會在每個package底下產生__pycache__ folder and .pyc, *.pyo file
一般而言這些file不會進入版本控管所以在.gitigore中通常會有
.py[co], pycache
但以上設定卻會在git branch switch時導致pyc, pyo殘留問題
以下介紹3種方法來處理

Continue reading

git config筆記

in git

git config三層設定

1
2
3
4
5
6
7
8
9
10
11
git config --system
針對所有使用者
/etc/gitconfig
git config --global
針對特定user
~/.gitconfig
git config
針對特定專案
.git/config
1
2
3
4
5
6
7
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
#防止中文亂碼
git config --global core.quotepath false
git config --global core.editor emacs
git config --global commit.template $HOME/.gitmessage.txt
git config --global color.ui true

Comment and share

git指令筆記

in git

基本

上一版本:HEAD^, 上兩版本HEAD~2, 上三版本HEAD~3…etc

1
2
3
4
git add [file]
git add -A
git commit -m [comment]
git push

Continue reading

Github筆記

in git

Github New Repository

  1. 申請github帳號
  2. create a empty public repository
  3. 在欲上傳的folder執行以下指令

    1
    2
    3
    4
    5
    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin https://github.com/cwza/gms.git
    git push -u origin master
  4. .gitignore筆記參考

  5. git筆記參考

  6. fetch remote branch and checkout it

    1
    2
    git fetch <remote> <rbranch>:<lbranch>
    git checkout <lbranch>

Update Github forked repository

1
2
3
4
5
6
7
git remote -v
git remote add upstream https://github.com/otheruser/repo.git
git fetch upstream
git branch -va
git checkout master
git merge upstream/master
git push

Comment and share

.gitignore筆記

in git

可將gitignore設定在以下三個地方,各代表不同意思

  • .gitignore

放在跟.git資料夾同一層
設定在這邊的代表此project需要忽略的,且此檔案會commit到git上,所以個人相關的不要放在這(ex: IDE產生的考慮放到下面那兩個)

.gitignore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# If you need to exclude files such as those generated by an IDE, use
# $GIT_DIR/info/exclude or the core.excludesFile configuration variable as
# described in https://git-scm.com/docs/gitignore
*.egg-info
*.pot
*.py[co]
__pycache__
MANIFEST
dist/
docs/_build/
docs/locale/
node_modules/
tests/coverage_html/
tests/.coverage
build/
tests/report/

  • $GIT_DIR/info/exclude
    $GIT_DIR通常就是.git folder
    設定在這邊的代表此project需要忽略的,不會被commit到git,專用來放個人相關的忽略

  • core.excludesFile
    全域忽略,所有project相關,在~/.gitconfig有此變數可設定

Comment and share

git submodule指令筆記

in git

add submodule

1
2
3
git submodule add http://github.com/tpope/vim-fugitive.git bundle/fugitive
git add .
git commit -m "Install Fugitive.vim bundle as a submodule."

remove submodule

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Run git rm –cached path_to_submodule (no trailing slash).
  5. Run rm -rf .git/modules/path_to_submodule
  6. commit git commit -m “Removed (submodule name)”
  7. Delete the now untracked submodule files rm -rf path_to_submodule
  8. git submodule sync

clone a project with git submodule

1
2
3
git clone <project>
git submodule init
git submodule update

Comment and share

  • page 1 of 1

Cwza

Hello everyone.
I’m cwza.
Welcome to my blog.


Software Engineer


Taiwan/Taipei