https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols
git clone path/to/repo
git clone file:///path/to/repo
git clone https://example.com/gitproject.git
git clone ssh://[[email protected]]server/project.git
git clone [[email protected]]server:project.git
git clone git://server/project.git
参考:
https://git-scm.com/docs/git-config
Examples:
[alias]
st = status
dfc = diff --cached
Tips:
!
から記述すると外部コマンドを記述できる参考:
別ファイルをincludeできる
[include]
path = .gitconfig.local
参考:
条件に基づいて別ファイルをincludeする。
参考:
https://git-scm.com/docs/git-config#Documentation/git-config.txt-pullff
pull時の挙動を設定する。
[pull]
# 以下いずれかを指定
ff = only # fast-forwardなマージのみ許可。マージコミットを作らない
ff = false # fast-forwardなときもマージコミットを作る
rebase = merges # rebaseする。ローカルのマージコミットは消失
rebase = preserve # マージコミットを保持してrebaseする
rebase = merges
だが、リモートと歴史が変わってしまったときにローカルの履歴が失われるリスクがあると思う。 rebase = preserve
なら大丈夫かもしれないff = only
は無難な設定ff = false
を設定したい理由はわからない関連項目:
参考:
See also gitコマンド
2020-06-20記入。
git diff > foo.diff
git apply foo.diff
今はこれでよいようだ。
メモ:
参考:
HEADのcommitを修正する場合:
git config --local user.name "YOUR NAME"
git config --local user.email [email protected]
git commit --amend --reset-author
過去の履歴についても変更したい場合:
git rebase -i <commit hash>
# 該当するコミットを `e` で選ぶ
git commit --amend --reset-author
git rebase --continue
参考:
See Git - 歴史の書き換え
## file
git filter-branch --tree-filter 'rm -f path/to/file' HEAD
## directory
git filter-branch --tree-filter 'rm -rf path/to/dir/' HEAD
参考:
merge commit を cherry-pick
git cherry-pick -m 1 <merge commit のハッシュ>
参考:
色んな人がやっていて、aliasに設定したりサブコマンドを作ったりしている。
自分でも2020-05-04に作った。
参考:
①.gitignore
や .git/info/exclude
を使う
②既に Git 管理下にあるファイルをワーキングツリーで敢えて除外する
git update-index —assume-unchanged [ファイル名]
git update-index —skip-worktree [ファイル名]
## 確認
git ls-files -v
## 取り消し
git update-index —no-assume-unchanged [ファイル名]
git update-index —no-skip-worktree [ファイル名]
git ls-files -v の表示:
参考:
git clone original_dir new_dir
cd new_dir
git filter-branch --subdirectory-filter sub_dir_name HEAD
参考:
参考:
長さ:
文法:
参考: