Skip to content

Instantly share code, notes, and snippets.

@akirakw
Created April 20, 2011 11:32
Show Gist options
  • Save akirakw/931042 to your computer and use it in GitHub Desktop.
Save akirakw/931042 to your computer and use it in GitHub Desktop.
作業で使ったGitのコマンドを淡々と書きとめるよ
# まずClone
git clone [email protected]:ashigeru/asakusafw.git
cd asakusafw
# リモートブランチのチェックアウト
git branch -a
git checkout -b dmdl origin/dmdl
# ほかのリポジトリのフェッチ
git remote add akirakw https://github.com/akirakw/asakusafw.git
git fetch akirakw
git branch -a
git checkout -b akirakw-dmdl akirakw/dmdl
# マージ
git branch
git checkout dmdl
git merge akirakw-dmdl
git status
git log
git diff HEAD~1
# プッシュ
git push origin dmdl
# 掃除
git branch -d akirakw-dmdl
# Commitをひとつにまとめる
git checkout master
git reset --hard
git status
git merge --squash dmdl
git commit
# centralのマージ確認中
# fetch central
git remote add central [email protected]:asakusafw/asakusafw.git
git fetch central
git checkout -b central-master central/master
# merge origin/master into central/master
git merge master
git status
git log
###############################
# 2011/4/25 rebaseを使った手順
###############################
# works on remote tracking branch
git fetch origin
git checkout -b <BRANCH> origin/<BRANCH>
git branch -a
...
git status
git diff
git add .
git commit
git push origin <BRANCH>
# merge to personal integration branch
git checkout master
git status
git rebase central/master
git merge --squash <BRANCH>
git status
git diff
git commit
git push origin master
# kick build job in jenkins
...
# merge to central integration branch (first)
git fetch central
git checkout -b central-master central/master
git rebase origin/master
git log
git push central central-master:master
# merge to central integration branch (after the second)
git checkout central-master
git pull central master
git rebase origin/master
git log
git push central central-master:master
###############################
# 2011/4/26 タグ付け
###############################
# タグを付けてpush
# GitHubと同期
git pull central master(or git push central master)
git pull origin master(or git push origin master)
# コミットを指定してタグ付け
git log
git tag -a 0.1.0 78d48010613f4e137a314a470c2248f1cba23656 -m "version 0.1.0"
git push origin --tags
git push central --tags
# 間違えて付けたタグの削除
git tag
git tag -d 0.1.0
git push origin :0.1.0
git push central :0.1.0
###########################################
# 2011/4/26 stashからbranchしてあとで取り込みメモ
# もっと良い方法があるかもしれない
###########################################
# masterでちょっとした変更(A)
edit A...
# (A)を始める前に戻って別の変更(B)を対応する
git stash
edit B...
git commit
# (A)と(B)は競合することがわかった...
# stash から branch を作る
git stash branch topicA
edit A...
git commit
(git push origin topicA)
# masterにマージ
git checkout master
git merge --squash topicA
resolve conflicts...
git add .
# ブランチの削除
git branch -D topicA
(git push origin :topicA)
#########################
# 2011/4/27 間違いからの回復
#########################
# centralをrebaseではなくpullしてoriginにpushしてしまった
# 取り込んだコミット分だけ戻す
git reset --hard HEAD~2
# rebaseしなおし
git rebase central/master
# force付きでoriginにpush
git push origin master --force
#########################
# BugFix基本形 modified 2011/5/9
# ※リリースブランチの場合はmasterを0.1などに置き換える。
#########################
# centralの最新をローカルのmasterに反映
git checkout master
git fetch central
git rebase central/master
# トピックブランチを作成してソース修正
git checkout -b issue-XX origin/master
[edit...]
git add .
git commit
(git push origin issue-XX)
[unit testing...]
# ローカルのintegration-branchにマージしてCI
git checkout master
#git fetch central
#git rebase central/master
git pull central master
git merge --no-commit --no-ff issue/XX
git diff --cached
git commit
git log origin/master...master
git push origin master
kick build job in jenkins
...
# centralへpush
git checkout central-master
git pull central master
git merge master
git log central/master...central-master
git commit --amend (optional?)
git push central central-master:master
# トピックブランチを削除
git branch -D issue-XX
(git push origin :issue-XX)
###############################
# 2011/6/17 リリースブランチ作成
###############################
git checkout central-master
git pull central master
git branch central-0.2
git checkout central-0.2
# pom.xmlのversionを変更する
git add .
git commit
git log
git push central central-0.2:0.2
###############################
# 掃除関連
###############################
git remote prune ashigeru
git gc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment