DevNet Associate (DEVASC) v1.0Software Development and DesignEasy
A developer is collaborating on a Python project using Git. They need to create a separate line of development to work on a new feature without affecting the main codebase. Once the feature is complete and tested, it will be merged back. Which Git command is used to create this separate line of development?
- Agit push
- Bgit commit
- Cgit clone
- Dgit branch
Show answer & explanationAnswer & explanation
Correct answer: D. git branch
`git branch` is used to create a new branch, which represents a separate line of development in Git. This allows developers to work on new features or bug fixes in isolation from the main branch.
Why the other options are wrong
- A. `git push` uploads local commits to a remote repository, used for sharing changes, not for creating new development lines.
- B. `git commit` saves changes to the local repository history, but does not create a new line of development.
- C. `git clone` copies an existing remote repository to a local machine, which is for initial setup, not for creating separate development lines within a project.
Git Branching
Git branching is a core feature that allows developers to diverge from the main line of development and continue to work in isolation without affecting the main codebase. Each branch represents an independent line of development.
- Creates separate lines of development
- Enables parallel work on features/fixes
- Lightweight and inexpensive to create
- Can be merged back into other branches
Memory trick: Branch off to explore new code paths, then merge back to the main route.