0Pricing
Linux Command Line Mastery · Lezione

Branching e merging con Git dalla riga di comando

Ampli le Sue conoscenze di base su Git lavorando con i branch: li crei, cambi, unisca, risolva i conflitti e segua un workflow ordinato basato sui feature branch.

Branching e merging con Git dalla riga di comando è una lezione Linux Command Line Mastery gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Linux Command Line Mastery, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Linux Command Line Mastery include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

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 branch

Creating 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-login

Committing 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 main

Merging a Branch

From main, git merge brings the feature commits in. A fast-forward happens when main has no new commits.

git merge feature-login

Handling 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 commit

Deleting 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-login

Comparing Branches

git diff between branches shows exactly what differs before you merge.

git diff main..feature-login

Pushing a Branch

Share a branch by pushing it and setting upstream tracking with -u.

git push -u origin feature-login

A 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 -c creates and moves to a branch
  • git merge integrates; conflicts are resolved by editing then committing
  • git branch -d cleans up merged branches
  • git push -u origin shares them

Branch per feature, merge when done.

Domande Frequenti

La lezione «Branching e merging con Git dalla riga di comando» è gratuita?

Sì — il testo completo di «Branching e merging con Git dalla riga di comando» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Linux Command Line Mastery, passa a CoddyKit PRO. Il corso Linux Command Line Mastery include 4 lezioni in totale.

Cosa imparerò in «Branching e merging con Git dalla riga di comando»?

Ampli le Sue conoscenze di base su Git lavorando con i branch: li crei, cambi, unisca, risolva i conflitti e segua un workflow ordinato basato sui feature branch. Eserciti Linux Command Line Mastery con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Linux Command Line Mastery?

Non è richiesta alcuna esperienza precedente. Linux Command Line Mastery su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Branching e merging con Git dalla riga di comando»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Linux Command Line Mastery?

Sì. Ogni lezione Linux Command Line Mastery include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Basi di Git dalla riga di comando
  2. Variabili d’ambiente e alias
  3. Configurazione della shell: `.bashrc`, `.zshrc`, `.profile`
  4. Branching e merging con Git dalla riga di comando
← Torna a Linux Command Line Mastery