0Pricing
Linux Command Line Mastery · Aula

Noções básicas de Git pela linha de comandos

Aprenda os comandos essenciais do Git para controle de versões, incluindo criação de commits, ramificações e mesclagens.

Noções básicas de Git pela linha de comandos é uma aula grátis de Linux Command Line Mastery no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Linux Command Line Mastery, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Linux Command Line Mastery inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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 init

Staging 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.md

Saving 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 --oneline

Parallel 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 branch

Switching 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' branch

Merging 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/login

Git 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!

Perguntas Frequentes

A aula “Noções básicas de Git pela linha de comandos” é grátis?

Sim — o texto completo de “Noções básicas de Git pela linha de comandos” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Linux Command Line Mastery, atualize para CoddyKit PRO. O curso de Linux Command Line Mastery inclui 4 aulas no total.

O que vou aprender em “Noções básicas de Git pela linha de comandos”?

Aprenda os comandos essenciais do Git para controle de versões, incluindo criação de commits, ramificações e mesclagens. Você pratica Linux Command Line Mastery com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Linux Command Line Mastery?

Nenhuma experiência prévia é necessária. Linux Command Line Mastery no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “Noções básicas de Git pela linha de comandos”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Linux Command Line Mastery?

Sim. Cada aula de Linux Command Line Mastery inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Noções básicas de Git pela linha de comandos
  2. Variáveis de ambiente e aliases
  3. Configuração do shell: `.bashrc`, `.zshrc`, `.profile`
  4. Ramificação e Mesclagem com Git pela Linha de Comando
← Voltar para Linux Command Line Mastery