Process Flow - Listing branches
Start in Git repo
Run 'git branch'
Git reads local branches
Display list of branches
End
The flow shows how Git lists all local branches when you run the 'git branch' command.
Jump into concepts and practice - no test required
git branch| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Run 'git branch' command | Git checks local branch references | Finds branches: main, feature1, bugfix |
| 2 | Prepare output list | Mark current branch with '*' | * main feature1 bugfix |
| 3 | Display branches to user | Output list shown in terminal | Branches listed with current branch marked |
| 4 | End | No more actions | Command completes |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| branches | empty | [main, feature1, bugfix] | [* main, feature1, bugfix] | [* main, feature1, bugfix] | [* main, feature1, bugfix] |
| current_branch | unknown | main | main | main | main |
git branch Lists all local branches in the current repository. The current branch is marked with '*'. To list remote branches, use 'git branch -r'. To list all branches (local + remote), use 'git branch -a'.
git branch show by default?git branchgit branch without any options lists only the local branches in your repository.-r option, and all branches require -a. So by default, it shows local branches only.git branch = local branches [OK]-r with git branch lists all remote branches.-a lists all branches (local + remote), but the question asks only for remote branches. The other options are invalid.-r means remote branches [OK]git branch by default lists only local branches. git branch -a lists all branches including remote, git branch -r lists only remote branches, and git branch --no-remote is invalid.git branch = local branches only [OK]git branch -a if your repository has local branches main, dev and remote branches origin/main, origin/feature?git branch -a output formatremotes/.main and dev appear without prefix. Remote branches appear as remotes/origin/main and remotes/origin/feature. The current branch is marked with *.-a shows all branches with remotes/ prefix [OK]git branch -r but got an error: error: unknown option '-r'. What is the likely cause?unknown option '-r', meaning Git does not recognize the -r flag.-r with git branch. Other options would give different errors or no error.-r -> Option D-r option [OK]