0
0
Gitdevops~5 mins

Pushing new branches to remote in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What command do you use to push a new local branch to a remote repository?
Use git push -u origin <branch-name> to push a new local branch to the remote repository and set it to track the remote branch.
Click to reveal answer
beginner
What does the -u flag do when pushing a new branch?
The -u flag sets the upstream (tracking) reference, so future git push and git pull commands know which remote branch to interact with by default.
Click to reveal answer
intermediate
How can you check which remote branches your local branches are tracking?
Run git branch -vv to see local branches with their tracking remote branches and last commit info.
Click to reveal answer
beginner
If you create a new branch locally but forget to push it, what happens when you run git push?
Git will not push the new branch because it has no upstream set. You must push it explicitly with git push -u origin <branch-name> the first time.
Click to reveal answer
beginner
Why is it important to push new branches to the remote repository?
Pushing new branches shares your work with others and backs up your changes. It also allows collaboration and code review on that branch.
Click to reveal answer
Which command pushes a new branch named 'feature' to the remote and sets it to track?
Agit push feature
Bgit push origin
Cgit push -u origin feature
Dgit push -u feature origin
What does 'origin' usually refer to in git commands?
AThe default name for the remote repository
BThe local branch name
CThe commit hash
DThe current directory
If you run git push without -u on a new branch, what happens?
APush fails because no upstream is set
BPush succeeds and sets upstream automatically
CPush deletes the branch
DPush merges branches
How do you see which remote branch your local branch is tracking?
Agit log
Bgit status
Cgit remote -v
Dgit branch -vv
Why might you want to push a new branch to remote early?
ATo delete the branch
BTo share work and enable collaboration
CTo reset the repository
DTo change the commit history
Explain the steps and command to push a new local branch to a remote repository and set it to track the remote branch.
Think about how to share your new work with others using git.
You got /3 concepts.
    Describe what happens if you try to push a new branch without setting upstream tracking and how to fix it.
    Remember the role of the -u flag.
    You got /3 concepts.