コマンドラインの Git でブランチを作成・マージする
ブランチを作成、切り替え、マージし、競合を解決することで Git の基礎を広げ、整理されたフィーチャーブランチのワークフローを身につけます。
「コマンドラインの Git でブランチを作成・マージする」はCoddyKit上の無料Linux Command Line Masteryレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはLinux Command Line Mastery学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Linux Command Line Masteryコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Why Branches?
You know how to commit and track files. Branches let you develop features in isolation without disturbing the main line of work, then merge them back when ready.
Listing Branches
git branch lists branches and marks the current one with an asterisk.
git branchCreating and Switching
git switch -c name creates a branch and moves to it in one step. (Older Git uses git checkout -b.)
git switch -c feature-loginCommitting on a Branch
Commits you make now belong only to the feature branch, leaving main untouched.
git add .
git commit -m 'Add login form'Switching Back
Return to main with git switch main. Your feature work is safely stored on its own branch.
git switch mainMerging a Branch
From main, git merge brings the feature commits in. A fast-forward happens when main has no new commits.
git merge feature-loginHandling Merge Conflicts
If the same lines changed on both branches, Git pauses and marks conflicts with <<<<<<< markers. Edit the file to resolve, then stage and commit.
git add resolved-file.txt
git commitDeleting Merged Branches
After merging, clean up with git branch -d. Git refuses if the branch is not merged, protecting your work.
git branch -d feature-loginComparing Branches
git diff between branches shows exactly what differs before you merge.
git diff main..feature-loginPushing a Branch
Share a branch by pushing it and setting upstream tracking with -u.
git push -u origin feature-loginA Clean Workflow
The feature-branch loop: branch from main, commit, push, open a pull request, merge, delete the branch. This keeps history organized and reviewable.
Quick Check
Which single command both creates a new branch and switches to it?
Recap
You can now manage parallel work:
git switch -ccreates and moves to a branchgit mergeintegrates; conflicts are resolved by editing then committinggit branch -dcleans up merged branchesgit push -u originshares them
Branch per feature, merge when done.
よくある質問
「コマンドラインの Git でブランチを作成・マージする」レッスンは無料ですか?
はい。「コマンドラインの Git でブランチを作成・マージする」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Linux Command Line Masteryコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Linux Command Line Masteryコースには全4レッスンが含まれています。
「コマンドラインの Git でブランチを作成・マージする」で何を学びますか?
ブランチを作成、切り替え、マージし、競合を解決することで Git の基礎を広げ、整理されたフィーチャーブランチのワークフローを身につけます。 ブラウザで直接実行するハンズオンコードでLinux Command Line Masteryを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Linux Command Line Masteryを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのLinux Command Line Masteryは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「コマンドラインの Git でブランチを作成・マージする」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このLinux Command Line Masteryレッスンでコードを書いて実行できますか?
はい。すべてのLinux Command Line Masteryレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- コマンドラインから始めるGitの基礎
- 環境変数とエイリアス
- シェルの設定:`.bashrc`、`.zshrc`、`.profile`
- コマンドラインの Git でブランチを作成・マージする