ログイン
編集不可のページディスカッション情報添付ファイル
alstamber/git

MMA

なにこれ

gitを運用する上での知識の整理。

local repositoryとremote repository

working directoryとindexとrepository

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 init

clone

clone local repository

git clone /path/to/repository

clone remote repository

git clone username@host:/path/to/repository

check

check status

git status

check differences of file

git diff <filename>

check repository log

git log

add/remove

add files

git add <filename>

git add *

remove files

git rm <filename>

commit

commit

git commit -m <message>

commit all file edited

git commit -a

push/pull

add remote repository

git remote add <name> <url>

git remote add origin <remote repository url>

push

git push <repository> <source_branch>:<target_branch>

pull

git pull <repository> <source_branch>:<target_branch>

git pull origin master

git pull origin hoge:hoge
git pull origin hoge

tracking branch

git pull

refs/heads/*:refs/remotes/origin/*

git pull origin refs/heads/*:refs/remotes/origin/*

git fetch origin refs/heads/*:refs/remotes/origin/*
git merge origin/master

branch

masterとtopic branch

stash

merge

rebase

A successful git branching model

create branch

git branch <branchname>

list branch

git branch

checkout branch

git checkout <branch>

create branch and checkout branch

git checkout -b <branchname>

merge branch

git merge <commit>

delete branch

git branch -d <branchname>

correct conflict

rebase branch

git rebase <branch>

git rebase --continue

show differences between two branches

git diff <source_branch> <target_branch>

pullとmerge

local repositoryのbranchに何も変更を加えていない時

local repositoryのbranchに変更をくわえている場合

fetch

tag

軽量タグと注釈付きタグ

add lightweight tag

git tag <tagname>

git tag <tagname> <commitID>

add annotated tag

git tag -a <tagname>

list tag

git tag

delete tag

git tag -d <tagname>

correct commit

revert

reset

reset commit

git reset --soft HEAD^

git diff ORIG_HEAD

とすれば差分を閲覧できる。

edit commit

commit --amend

cherry-pick

rebase -i

squash

amendを使う

git commit(あっ間違えた!)
(間違いを修正)
git commit --amend

HEADの状態にworking directoryにあるファイルを戻す

git checkout -- <filename>

commitの編集方法使い分け

あれこれゴミコードを書いてみたけどもう要らない

git reset --hard HEAD~{n}

topic branchをmergeしたけど実はまだ不完全だった。mergeをやり直したい。

git reset --hard ORIG_HEAD

pushしたあとに自分のやったcommitにバグがあることが判明。元に戻したい

other

garbage correction

git gc

installation gitlab

alstamber/git (最終更新日時 2012-09-07 22:43:21 更新者 alstamber)