ローカルリポジトリを最新版にして、プッシュするまでの流れ
まずはmasterブランチを最新の状態にする
masterに移動
git checkout master
upstream(fork元)から最新のものを取ってくる
git fetch upstream
fetchしたものをローカルのmasterに反映させる(ローカルのmasterを最新にする)
git rebase upstream/master
最新にしたmasterをプッシュしておく
git push origin master
作業ブランチのコミットを1つにまとめてから最新にする
作業ブランチへ移動
git checkout 作業してるブランチ名
作業中のものを避ける
git stash
masterと差分のコミットを一つにまとめる
git rebase -i master
すると、こんな感じのが出てくる
pick ai9j38h 新機能追加 pick onw832h 修正 pick ji8h84h エラー修正 # Rebase bdd3996..bd66e17 onto bdd3996 # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. #
i
を押してINSERTモードにして二つ目以降のコミットのpick
をsquash
へ変更する
pick ai9j38h 新機能追加 squash onw832h 修正 squash ji8h84h エラー修正 # Rebase bdd3996..bd66e17 onto bdd3996 # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. #
esc
を押して、:wq
で保存する
作業してるブランチを最新にする
git rebase master 作業してるブランチ名
コンフリクトしたら、奴らと戦う
最新にした作業ブランチをプッシュ
git push origin 作業してるブランチ名
Java Gradle マルチプロジェクト作成方法
プロジェクト構成
multi-sample +--- sample-common +--- sample-core (sample-commonに依存)
- multi-sampleの直下でGradleによるプロジェクト初期化
gradle init
- settings.gradleを編集
rootProject.name = 'multi-sample' include "sample-common", "sample-core"
- build.gradleを編集
subprojects { apply plugin: 'eclipse' apply plugin: 'java' apply plugin: 'idea' def defaultEncoding = 'UTF-8' tasks.withType(JavaCompile) { options.encoding = defaultEncoding } sourceCompatibility = 1.8 targetCompatibility = 1.8 project.ext { authorName = 'YOUR NAME' dropwizardVersion = 'バージョン' } repositories { mavenCentral() } dependencies { compile "io.dropwizard:dropwizard-core:${dropwizardVersion}" } version = '1.0' task wrapper(type: Wrapper) { gradleVersion = '2.14' } } project(':sample-common') { } project(':sample-core') { dependencies { compile project(':sample-common') } }
gradle eclipse
を叩く
git rebase・squash
rebase
今までのコミットしてきたものの上にmasterのコミットをポンっと置くイメージ。
rebaseするときは一旦新たにブランチを切ってから行うべし。
squash
コミットを一つにまとめる
squashの流れ
コマンドでコミットのログを見る
git log --oneline
を叩くと、
nanako:gtest nanako$ git log --oneline a0de58f last commit 1574f49 sample3 17a75e7 sample2 6b45ec9 sample1 791c07e first commit
sample1、sample2、sample3をcommit all
としてコミットをまとめるとすると、
git rebase -i 791c07e
を叩くと、下のものが出てくる。
pick 6b45ec9 sample1 pick 17a75e7 sample2 pick 1574f49 sample3 pick a0de58f last commit
sample2とsample3のpick
の部分をs
に変更して上書き保存。
コミットのメッセージが表示されるので、first commit's message is
に描かれているsample1
を消して、commit all
と書いて上書き保存。
再度コミットのログを確認
git log --oneline
a0de58f last commit 84yeu43 commit all 791c07e first commit