Gitは大事。gitをもっと理解する【Day 90 of 100】

—

by

in

,
user@USERnoMacBook-Pro tutorial % git branch feature-A
user@USERnoMacBook-Pro tutorial % git branch
feature-A
* main
user@USERnoMacBook-Pro tutorial % git checkout feature-A
Switched to branch 'feature-A'
user@USERnoMacBook-Pro tutorial % git branch
* feature-A
main
user@USERnoMacBook-Pro tutorial % git checkout main
Switched to branch 'main'
Your branch is ahead of 'origin/main' by 6 commits.
(use "git push" to publish your local commits)
user@USERnoMacBook-Pro tutorial % git branch
feature-A
* main
user@USERnoMacBook-Pro tutorial % git checkout feature-A
Switched to branch 'feature-A'
user@USERnoMacBook-Pro tutorial % git branch
* feature-A
main
user@USERnoMacBook-Pro tutorial % git add a.js
user@USERnoMacBook-Pro tutorial % git diff HEAD
diff --git a/git_basics/tutorial/a.js b/git_basics/tutorial/a.js
index ae17ca4..5599dae 100644
--- a/git_basics/tutorial/a.js
+++ b/git_basics/tutorial/a.js
@@ -2,3 +2,4 @@ console.log('A is edited');
console.log('ほげほげ');
console.log('まみまみ');
console.log('ぷーぷー');
+console.log('feature-A');
user@USERnoMacBook-Pro tutorial % git commit -m "update to feature-A"
[feature-A 50a5899] update to feature-A
1 file changed, 1 insertion(+)
user@USERnoMacBook-Pro tutorial % git checkout main
Switched to branch 'main'
Your branch is ahead of 'origin/main' by 6 commits.
(use "git push" to publish your local commits)
user@USERnoMacBook-Pro tutorial % git branch
feature-A
* main
user@USERnoMacBook-Pro tutorial % git checkout feature-A
Switched to branch 'feature-A'
user@USERnoMacBook-Pro tutorial % git checkout main
Switched to branch 'main'
Your branch is ahead of 'origin/main' by 6 commits.
(use "git push" to publish your local commits)
user@USERnoMacBook-Pro tutorial % git checkout -
Switched to branch 'feature-A'
user@USERnoMacBook-Pro tutorial % git checkout feature-A
Already on 'feature-A'
user@USERnoMacBook-Pro tutorial %

git branch feature-A branchのfeature-Aを作成する

git branch 今どんなbranchがあるのか、どこにいるのか表示する

git checkout main チェックアウトと言ってもどっちかといえばチェックイン。mainに移動

git checkout - 直前のブランチに移動

feature-Aブランチを main ブランチにmergeした

git checkout main まずくっつけて残したい幹の方に移動
Switched to branch ‘main’
Your branch is ahead of ‘origin/main’ by 6 commits.
(use “git push” to publish your local commits)


user@USERnoMacBook-Pro tutorial % git merge –no-ff feature-A –no-ffで履歴を残しながらマージ

user@USERnoMacBook-Pro tutorial % git config –global core.editor “vim” 編集ソフトをvimになってなかったからvimに設定
user@USERnoMacBook-Pro tutorial % git commit さっきエラーになったところから再度commit
[main 99c6b28] Merge branch ‘feature-A’
user@USERnoMacBook-Pro tutorial %

branchをつくってはmergeの練習

git branch bull //ブルブランチをつくる

git branch //ブランチ一覧と今どのブランチか確認

git checkout bull //bullブランチに移動

b.js ファイルを編集し保存し

git add b.js //b.jsファイルをステージに上げる

git commit -m “ブランチbullにコンソールログ追加” //コミットする

git checkout main  //mainブランチに移動

git merge –no-ff bull //bullをmainにマージする。ff早送りしない→エディターが立ち上がる。そのまま:wq

: はコマンド開始

w は保存(write)

q は終了(quit)

を入力してコミット履歴を残す

git log –graph コマンド

conflictを解決する


コメントを残す

猫でデザインとプログラミングを学ぶをもっと見る

今すぐ購読し、続きを読んで、すべてのアーカイブにアクセスしましょう。

続きを読む