Skip to content

Instantly share code, notes, and snippets.

@7cc
Last active March 21, 2019 09:24
Show Gist options
  • Select an option

  • Save 7cc/180ec5e574f8fe561d1a8e2c53079671 to your computer and use it in GitHub Desktop.

Select an option

Save 7cc/180ec5e574f8fe561d1a8e2c53079671 to your computer and use it in GitHub Desktop.
git config --global alias.up '!git remote update --prune; git merge --ff-only @{upstream}'
<repo> <branch> <commit>
# diff
git show /= git diff HEAD^ = git diff HEAD^..HEAD
git diff HEAD dev # branch
git diff HEAD v1 # tag
git diff @{u} # remote =? git diff FETCH_HEAD
# 更新
git fetch origin master
git remote update (origin) = git fetch --all
# merge と pull
git merge origin/master
git pull = fetch + merge
git pull --rebase = fetch + rebase
git push
git push origin
git push origin master
#--------------------
# branch間でもfetch, pullできる
git fetch . dev
git diff HEAD FETCH_HEAD
git pull . dev
# 意味は無い
git fetch . v1 # tag
git fetch . HEAD # commit
<< !
https://stackoverflow.com/questions/21756614/difference-between-git-merge-origin-master-and-git-pull
https://stackoverflow.com/questions/25430600/difference-between-git-pull-rebase-and-git-pull-ff-only
http://kray.jp/blog/git-pull-rebase/
https://www.slideshare.net/kotas/git-15276118
!

設定ファイル

設定ファイルの場所

  • --? "C:\ProgramData/Git/config"
  • --system gitのある場所 C:/Program Files/Git/mingw64/etc/gitconfig
  • --global $USERHOME ~/.gitconfig
  • --local project

設定の確認

# 適用されているエディタ設定
git config --get core.editor
# 特定の場所でのエディタ設定
git config --global --get core.editor
# 全ての場所でのエディタ設定
git config --get-all core.editor
# 特定の場所での全ての設定
git config --system --list
# 全ての場所での全ての設定
git config --list --show-origin

設定ファイルの種類

「個人で使うもの」と「共有するもの」

  • 個人で使うもの
    • .gitconfig 個人設定 user.name や core.editor など
    • .gitignore_global 環境固有のファイルをignore 別の名前でもいい
    • .gitattributes_global 別の名前でもいい
  • 共有するもの
    • .gitattributes
    • .gitignore

crlf

結論: .gitattributes を設定する。他は忘れてもいい。
設定を変えながら git add . --dry-run で試す。

new

  • .gitattributes (project/.gitattributes)
  • core.attributesFile (~/.gitconfig)

old

~/.gitconfig

  • core.eol native/lf/crlf
  • core.autocrlf false/true/input
  • core.safecrlf warn/true/false

.gitconfig example

*               text=auto
*.txt		text
*.sh		text eol=lf
*.cmd		text eol=crlf
*.bat		text eol=crlf
*.jpg		-text
*.jpeg		-text
*.png		-text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment