Git-Grundlagen über die Befehlszeile
Lernen Sie wichtige Git-Befehle für die Versionsverwaltung kennen, darunter Committen, Branching und Merging.
Git-Grundlagen über die Befehlszeile ist eine kostenlose Linux Command Line Mastery-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Linux Command Line Mastery-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Linux Command Line Mastery-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
What is Git?
Welcome to Git basics! Git is a powerful Version Control System (VCS). Think of it as a super-smart history book for your code.
It tracks every change you make, letting you revert to older versions, collaborate with others, and manage different features without stepping on toes. It's essential for modern software development!
Starting a Git Project
To begin tracking a project with Git, you first need to initialize a repository. This creates a special .git folder in your project, where Git stores all its tracking information.
Use the git init command in your project's root directory.
mkdir my_project
cd my_project
git initStaging Your Changes
Before saving your work, Git uses a 'staging area'. This is like a rough draft space where you select which changes you want to include in your next save.
The git add command is used to add files or changes to this staging area.
echo "My first line." > README.md
git add README.mdSaving Your Work (Commit)
Once changes are staged, you 'commit' them. A commit is a snapshot of your project at a specific point in time, with a descriptive message.
Use git commit -m "Your message" to save staged changes to your repository's history.
git commit -m "Initial commit: Added README.md"Viewing Project History
Git keeps a detailed log of all your commits. You can review this history to see who made what changes and when.
The git log command displays your repository's commit history. The --oneline option provides a concise view.
git log --onelineParallel Development with Branches
Branches are a core concept in Git. They allow you to diverge from the main line of development and continue working without affecting the main project.
- Work on new features.
- Fix bugs without breaking stable code.
- Experiment with new ideas.
The main (or master) branch is typically the stable version.
Creating a New Branch
To start a new line of development, you create a new branch. This doesn't move you to the new branch yet; it just creates it.
The git branch <branch-name> command creates a new branch. You can list all branches with just git branch.
git branch feature/login
git branchSwitching Between Branches
After creating a branch, you need to switch to it to start working on that specific line of development. Your files will reflect the state of that branch.
Use git switch <branch-name> to move to an existing branch. It's the modern way to navigate branches.
git switch feature/login
# Now you are on the 'feature/login' branchMerging Branches
Once you've finished work on a feature branch, you'll want to integrate those changes back into your main development line, usually the main branch.
First, switch to the target branch (e.g., main), then use git merge <source-branch> to bring in the changes.
git switch main
git merge feature/loginGit Workflow Check
You've learned the core steps for managing changes with Git. Let's test your understanding of how to save your work.
Git Basics Summary
Great job! You've learned the fundamental Git commands:
git init: To start a new repository.git add: To stage changes for a commit.git commit: To save staged changes to history.git log: To view your project's commit history.git branch: To create and list branches.git switch: To move between branches.git merge: To combine changes from different branches.
These commands form the backbone of managing your code with Git!
Häufig gestellte Fragen
Ist die Lektion „Git-Grundlagen über die Befehlszeile“ kostenlos?
Ja — der vollständige Text von „Git-Grundlagen über die Befehlszeile“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Linux Command Line Mastery-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Linux Command Line Mastery-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Git-Grundlagen über die Befehlszeile“?
Lernen Sie wichtige Git-Befehle für die Versionsverwaltung kennen, darunter Committen, Branching und Merging. Du übst Linux Command Line Mastery mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Linux Command Line Mastery zu starten?
Keine Vorkenntnisse erforderlich. Linux Command Line Mastery auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.
Wie lange dauert die Lektion „Git-Grundlagen über die Befehlszeile“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Linux Command Line Mastery-Lektion Code schreiben und ausführen?
Ja. Jede Linux Command Line Mastery-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Git-Grundlagen über die Befehlszeile
- Umgebungsvariablen und Aliase
- Shell-Konfiguration: `.bashrc`, `.zshrc`, `.profile`
- Branching und Merging mit Git über die Kommandozeile