Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Switching and Working on Branches | Branching Out: Exploring New Ideas Safely
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Git and GitHub for Absolute Dummies

bookSwitching and Working on Branches

When you use Git, you can move between branches to work on different things, just like switching between drafts of a story. Each branch is a separate version of your project, so you can try out new ideas without affecting your main work. This makes it easy to experiment, fix bugs, or add features, all while keeping your main project safe and organized.

# To switch back to your main branch, use:
git checkout main

When you switch branches, Git updates your files to match the version saved on that branch. Any changes you made on your previous branch stay there, and you can safely pick up where you left off when you return. This means your work is kept safe and separate, so you do not lose progress or mix up changes between different ideas.

# Suppose you're on a branch called 'feature-idea'
git add new-feature.txt
git commit -m "Add new feature"

# This commit only affects 'feature-idea' branch.
# The main branch ('main') does not have 'new-feature.txt' or this commit.

1. What does 'git checkout main' do?

2. If you make a change on a branch, does it affect the main branch?

question mark

What does 'git checkout main' do?

Select the correct answer

question mark

If you make a change on a branch, does it affect the main branch?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 2

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Can you explain what happens if I have uncommitted changes when switching branches?

How do I create a new branch and switch to it?

What should I do if I get an error while switching branches?

bookSwitching and Working on Branches

Свайпніть щоб показати меню

When you use Git, you can move between branches to work on different things, just like switching between drafts of a story. Each branch is a separate version of your project, so you can try out new ideas without affecting your main work. This makes it easy to experiment, fix bugs, or add features, all while keeping your main project safe and organized.

# To switch back to your main branch, use:
git checkout main

When you switch branches, Git updates your files to match the version saved on that branch. Any changes you made on your previous branch stay there, and you can safely pick up where you left off when you return. This means your work is kept safe and separate, so you do not lose progress or mix up changes between different ideas.

# Suppose you're on a branch called 'feature-idea'
git add new-feature.txt
git commit -m "Add new feature"

# This commit only affects 'feature-idea' branch.
# The main branch ('main') does not have 'new-feature.txt' or this commit.

1. What does 'git checkout main' do?

2. If you make a change on a branch, does it affect the main branch?

question mark

What does 'git checkout main' do?

Select the correct answer

question mark

If you make a change on a branch, does it affect the main branch?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 2
some-alt