Skip to content

Instantly share code, notes, and snippets.

@ksauzz
Created January 10, 2012 11:17
Show Gist options
  • Save ksauzz/1588523 to your computer and use it in GitHub Desktop.
Save ksauzz/1588523 to your computer and use it in GitHub Desktop.
Git memo

git memo

commit

git commit -m msg
git commit --amend

checkout

git checkout -b branch_name

rm

remove from index

git rm --cached item

reset

git reset .
git reset --soft HEAD^
git reset --hard HEAD^

rebase

rebase -i HEAD^^^
rebase --onto base_branch current_branch branch

git svn

標準ディレクトリ構成にてクローン git svn clone -s --prefix=svn/ repo_url
clone時のリビジョン指定(depth) git svn clone -s --prefix=svn/ -r $REV:HEAD repo_url
svnの変更に追従 git svn rebase
svnへコミット git svn dcommit
svnリポジトリの変更を取得 git svn fetch svn
svn側にブランチ作成 git svn branch branch_name
svn側にタグ打ち git svn tag version (-n dry-run)
svnブランチに紐付くローカルブランチの作成 git branch local_branch_name remotes/svn/branch_name git checkout -b local_branch_name remotes/svn/branch_name

merge時の注意

svnブランチを参照しているブランチからmergeするときは``--no-ff``オプションを使うこと。fast-fowardだとremoteブランチが切り替わる。 誤って実行した場合はreset等で対処。

ローカルブランチのコミットを履歴を維持したままsvnブランチへコミットする

git branch local_branch
// edit & commit
git svn branch remote_branch
git checkout -b svn_sync_branch remotes/svn/remote_branch
git rebase svn_sync_branch
git svn dcommit

git branch

git reflog

rebase前の情報を取得 git reflog show branch_name

git clean

.gitignoreを無視 git clean -x
ディレクトリも削除 git clean -d

change author and commiter

git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "old_name" ]; then
    GIT_AUTHOR_NAME="new_author_name"
    GIT_AUTHOR_EMAIL="new_author_email"
    GIT_COMMITTER_NAME="new_comitter_name"
    GIT_COMMITTER_EMAIL="new_commiter_email"
fi
git commit-tree "$@"
' HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment