Git: Difference between revisions
From Mintarc Forge
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
<< [[ひよっこ書庫]] | << [[ひよっこ書庫]] | ||
Gitに触れてみた記録 | Gitに触れてみた記録 | ||
| Line 36: | Line 35: | ||
で<br/> | で<br/> | ||
<pre> | |||
$ git status | $ git status | ||
On branch master | On branch master | ||
| Line 44: | Line 44: | ||
(use "git rm --cached <file>..." to unstage) | (use "git rm --cached <file>..." to unstage) | ||
new file: newFile.txt | new file: newFile.txt | ||
</pre> | |||
git commit -m "初めてのコミット" | git commit -m "初めてのコミット" | ||
<pre> | |||
$ git status | $ git status | ||
On branch master | On branch master | ||
| Line 56: | Line 57: | ||
no changes added to commit (use "git add" and/or "git commit -a") | no changes added to commit (use "git add" and/or "git commit -a") | ||
</pre> | |||
git add . | git add . | ||
| Line 63: | Line 65: | ||
git log | git log | ||
<pre> | |||
$ git log | $ git log | ||
commit c049436e84acc752b875fa98a629467d0b6ec321 (HEAD -> master) | commit c049436e84acc752b875fa98a629467d0b6ec321 (HEAD -> master) | ||
| Line 75: | Line 78: | ||
初めてのコミット | 初めてのコミット | ||
</pre> | |||
git diff | git diff | ||
<pre> | |||
$ git diff | $ git diff | ||
diff --git a/newFile.txt b/newFile.txt | diff --git a/newFile.txt b/newFile.txt | ||
| Line 87: | Line 92: | ||
新しい行を追加 | 新しい行を追加 | ||
+消される運命にある一行 | +消される運命にある一行 | ||
</pre> | |||
$ git restore newFile.txt | $ git restore newFile.txt | ||
<pre> | |||
$ git branch | $ git branch | ||
* master | * master | ||
</pre> | |||
$ git branch feature1 | |||
$ git branch feature2 | $ git branch feature2 | ||
<pre> | |||
$ git branch | $ git branch | ||
feature1 | feature1 | ||
feature2 | feature2 | ||
* master | * master | ||
</pre> | |||
$ git switch feature1 | $ git switch feature1 | ||
<pre> | |||
$ git branch | $ git branch | ||
* feature1 | * feature1 | ||
feature2 | feature2 | ||
master | master | ||
</pre> | |||
git add . | git add . | ||
| Line 125: | Line 136: | ||
$ git merge feature1 | $ git merge feature1 | ||
<pre> | |||
$ git merge feature1 | $ git merge feature1 | ||
Updating c049436..86960d3 | Updating c049436..86960d3 | ||
| Line 130: | Line 142: | ||
newFile.txt | 1 + | newFile.txt | 1 + | ||
1 file changed, 1 insertion(+) | 1 file changed, 1 insertion(+) | ||
</pre> | |||
$ git merge feature2 | $ git merge feature2 | ||
<pre> | |||
$ git merge feature2 | $ git merge feature2 | ||
Auto-merging newFile.txt | Auto-merging newFile.txt | ||
CONFLICT (content): Merge conflict in newFile.txt | CONFLICT (content): Merge conflict in newFile.txt | ||
Automatic merge failed; fix conflicts and then commit the result. | Automatic merge failed; fix conflicts and then commit the result. | ||
</pre> | |||
git add . | git add . | ||
| Line 143: | Line 157: | ||
$ git commit -m "完成" | $ git commit -m "完成" | ||
<pre> | |||
$ git branch | $ git branch | ||
feature1 | feature1 | ||
feature2 | feature2 | ||
* master | * master | ||
</pre> | |||
$ git branch -d feature1 | $ git branch -d feature1 | ||
| Line 152: | Line 168: | ||
$ git branch -d feature2 | $ git branch -d feature2 | ||
<pre> | |||
$ git branch | $ git branch | ||
* master | * master | ||
</pre> | |||
<< [[ひよっこ書庫]] | << [[ひよっこ書庫]] | ||
Revision as of 23:20, 27 May 2026
<< ひよっこ書庫 Gitに触れてみた記録
2026/05/21
参考にした動画:https://youtu.be/cyOTQzI2AFU?si=CJSALJrGVrLPr3co
VCcode、Git bashをインストールした。
Git bash
- ユーザー名、メールアドレス登録
$ git config --grobal user.name 任意の名前'
でユーザー名を設定。
$ git config --grobal user.email メールアドレス
でメールアドレスを設定。
- リポジトリの初期化、ファイル作成
$ git init
「 GitTest というファイルの中身をバージョン管理していきますよ」をこのコマンドにより知らせた。
実行したことで GitTest フォルダの中に .git という目に見えない隠しフォルダが作られた。
(隠しフォルダも表示されるようにあらかじめ設定したので、今回は見えている)
2026/05/26
参考にした動画:https://youtu.be/cyOTQzI2AFU?si=CJSALJrGVrLPr3co
5/21の続き。
Git bash
- まずはファイルへ移動
cd /c/Users/makko/Desktop/GitTest
で GitTest フォルダに移動。
- hjsahあsjh
git add newFile.txt
で
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: newFile.txt
git commit -m "初めてのコミット"
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: newFile.txt
no changes added to commit (use "git add" and/or "git commit -a")
git add .
git commit -m "新しい行の追加"
git log
$ git log
commit c049436e84acc752b875fa98a629467d0b6ec321 (HEAD -> master)
Author: makoto <araheu15akim@gmail.com>
Date: Tue May 26 08:02:50 2026 +0900
新しい行の追加
commit 4aa851f08a6abf5ae22e956b377caaebac437166
Author: makoto <araheu15akim@gmail.com>
Date: Tue May 26 08:00:48 2026 +0900
初めてのコミット
git diff
$ git diff diff --git a/newFile.txt b/newFile.txt index 1c90f50..7529f41 100644 --- a/newFile.txt +++ b/newFile.txt @@ -1,2 +1,3 @@ これは新しいファイルです 新しい行を追加 +消される運命にある一行
$ git restore newFile.txt
$ git branch * master
$ git branch feature1
$ git branch feature2
$ git branch feature1 feature2 * master
$ git switch feature1
$ git branch * feature1 feature2 master
git add .
$ git commit -m "feature1の変更点"
$ git switch feature2
git add .
$ git commit -m "feature2の変更点"
$ git switch master
$ git merge feature1
$ git merge feature1 Updating c049436..86960d3 Fast-forward newFile.txt | 1 + 1 file changed, 1 insertion(+)
$ git merge feature2
$ git merge feature2 Auto-merging newFile.txt CONFLICT (content): Merge conflict in newFile.txt Automatic merge failed; fix conflicts and then commit the result.
git add .
$ git commit -m "完成"
$ git branch feature1 feature2 * master
$ git branch -d feature1
$ git branch -d feature2
$ git branch * master
<< ひよっこ書庫
