LoginSignup
2
2

More than 5 years have passed since last update.

gitでいろいろ

Last updated at Posted at 2013-10-08

gitでいろいろ

mergeの仕方

developブランチをnowブランチにmergeするとき.

git checkout now
git fetch origin --prune
git merge origin/develop

pushの仕方

add、commit、merge後に

git push origin now

remote branch名とlocal branch名が異なる場合。

git push origine local-branch:remote-branch

remoteにpushしたcommitを消す

git log

で戻りたい所のcommit id を見る。
ex. 7f68164e9e72ee0378aab34f43b3bc13cbb6e3bbまで戻りたい

git reset --hard 7f68164e9e72ee0378aab34f43b3bc13cbb6e3bb←こいつは消さない
git push -f origin master

mergeやpullのため一時的にHEADを保存

git stash save
git stash list
git stash pop

remoteのbranchをlocalに持ってくる

git branch new-branch origin/new-branch

checkoutも一緒にやりたい場合

git checkout -b new-branch origin/new-branch

git logのemailやnameを変える

やりたい事: nameがdodotanakaのcommitのnameをnewnewtanakaに変える

git log --pretty=format:"%h%x09%an%x09%ad%x09%s" | grep 'dodotanaka'

git logから'dodotanaka'が含まれているものだけ抽出

git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "dodotanaka" ]; then
GIT_COMMITTER_NAME="newnewtanaka"
fi
git commit-tree "$@"
' HEAD

git logを真っ新にしたい.

rm -rf .git
git init

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2