300-435 · Question #21
A new project called "device_status" must be stored in a central Git repository called "devops_status" with the first file named "device_status.py". The Git repository is created using the account…
The correct answer is A. git init git add device_status.py git commit -m "Initial Revision" git remote add origin \ https://git.cisco.com/python_programmer/device_status.git git push -u origin master. The correct sequence of Git commands for an initial project push involves initializing the repository, staging and committing files, adding a remote origin, and then pushing the local branch to the remote.
Question
Options
- Agit init
git add device_status.py
git commit -m "Initial Revision"
git remote add origin
https://git.cisco.com/python_programmer/device_status.git git push -u origin master - Bgit init
git remote add origin
https://git.cisco.com/python_programmer/device_status.git git add device_status.py git pull - Cgit init
git remote add origin
https://git.cisco.com/python_programmer/device_status.git git add device_status.py git commit -m "Initial Revision" git pull -u origin master - Dgit init git add device_status.py git remote add python_programmer/device_status git push
How the community answered
(61 responses)- A90% (55)
- B2% (1)
- C3% (2)
- D5% (3)
Why each option
The correct sequence of Git commands for an initial project push involves initializing the repository, staging and committing files, adding a remote origin, and then pushing the local branch to the remote.
This sequence correctly initializes a new Git repository (`git init`), stages the file (`git add`), commits it locally (`git commit`), associates the local repository with the remote URL (`git remote add origin`), and finally pushes the master branch to the remote, setting it as the upstream tracking branch (`git push -u origin master`). This is the standard workflow for an initial project push.
This sequence is incorrect because `git pull` is used to fetch and merge changes from a remote, which is not appropriate for an initial push where no history exists on the remote yet, and it misses the `git commit` step entirely.
This sequence incorrectly uses `git pull -u origin master` after committing, which is typically for synchronizing with an existing remote; for an initial push, `git push` is required to send local changes to the remote.
This sequence is incorrect because `git remote add python_programmer/device_status` is missing the remote URL, and `git push` without specifying the remote and branch might fail or require prior configuration.
Concept tested: Git basic workflow - initial commit and push
Source: https://git-scm.com/docs/gittutorial
Topics
Community Discussion
No community discussion yet for this question.