0
0
Gitdevops~20 mins

Pushing new branches to remote in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Branch Pushing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of pushing a new branch to remote?
You created a new branch named feature-x locally. You run git push origin feature-x. What is the expected output?
Git
git push origin feature-x
Afatal: remote origin already exists.
B
error: src refspec feature-x does not match any.
fatal: failed to push some refs to 'github.com:user/repo.git'
CEverything up-to-date
D
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 350 bytes | 350.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'feature-x' on GitHub:
remote:   https://github.com/user/repo/pull/new/feature-x
To github.com:user/repo.git
 * [new branch]      feature-x -> feature-x
Attempts:
2 left
💡 Hint
Think about what happens when you push a branch that exists locally but not yet on remote.
🧠 Conceptual
intermediate
1:30remaining
Why do you need to push a new branch explicitly to remote?
You created a new branch locally but your teammate cannot see it on the remote repository. Why is pushing the new branch necessary?
ABecause pushing deletes the branch from local.
BBecause git automatically pushes all branches when you commit locally.
CBecause branches are local by default and must be pushed to be visible on remote.
DBecause remote repositories do not support branches.
Attempts:
2 left
💡 Hint
Think about the difference between local and remote repositories.
Troubleshoot
advanced
1:30remaining
What error occurs if you try to push a branch that does not exist locally?
You run git push origin feature-y but you never created feature-y locally. What error will git show?
Git
git push origin feature-y
A
error: src refspec feature-y does not match any.
fatal: failed to push some refs to 'origin'
BEverything up-to-date
Cfatal: remote origin already exists.
Dfatal: could not read Username for 'https://github.com': No such device or address
Attempts:
2 left
💡 Hint
Check if the branch exists locally before pushing.
🔀 Workflow
advanced
2:30remaining
What is the correct sequence to create and push a new branch to remote?
Arrange the steps in the correct order to create a new branch feature-z and push it to remote.
A3,4,1,2
B1,3,4,2
C1,4,3,2
D3,1,4,2
Attempts:
2 left
💡 Hint
You must create the branch first, then add and commit changes, then push.
Best Practice
expert
1:30remaining
Which command safely pushes a new branch and sets upstream tracking in one step?
You want to push your new branch feature-new to remote and set it to track the remote branch automatically. Which command achieves this?
Agit push -u origin feature-new
Bgit push origin feature-new --force
Cgit push origin feature-new:feature-new
Dgit push origin --all
Attempts:
2 left
💡 Hint
Look for the option that sets upstream tracking.