なにこれ
gitを運用する上での知識の整理。
initial settings
git config --global user.name "<username>" git config --global user.email "<mail address>"
create
create new repository
git init
create new public repository
- 慣例としてディレクトリ名に.gitをつける。
- --bareをつけると、bare repositoryになる。bare repositoryは管理情報のみを持つ。
- commitなどができない。
git --bare init
clone
clone local repository
- 既存のlocal repositoryを複製する。
git clone /path/to/repository
clone remote repository
- 既存のremote repositoryを複製する。
git clone username@host:/path/to/repository
check
check status
- working directoryとindexの状態を確認する。
git status
check repository log
- repositoryの変更履歴を確認する。
git log
add/remove
add files
- indexにaddする。
git add <filename>
- すべてをaddする。
git add *
remove files
- indexからremoveする。
git rm <filename>
commit
commit
git commit -m <message>
push/pull
add remote repository
- push/pullするためにremote repositoryを予め登録しておく。
git remote add <name> <url>
- 通例次のように使う。
- push/pullでrepository名を省略するとoriginという名前につなぎに行こうとするので。
git remote add origin <remote repository url>
push
<repository>に<branch>をpushする。
- cloneして生成したrepositoryではgit pushだけでgit push origin masterと同じ事になる。
git push <repository> <branch>...
pull
<repository>をとってきて<branch>にmergeする。
git pull <repository> <branch>