exam questions

Exam AZ-400 All Questions

View all questions & answers for the AZ-400 exam

Exam AZ-400 topic 8 question 10 discussion

Actual exam question from Microsoft's AZ-400
Question #: 10
Topic #: 8
[All AZ-400 Questions]

DRAG DROP -
You manage the Git repository for a large enterprise application.
During the development of the application, you use a file named Config.json.
You need to prevent Config.json from being committed to the source control whenever changes to the application are committed.
Which three actions should you perform in sequence? To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Step 1: Delete and recreate the repository.
Step 2: Add Config.json to the .gitignore file
Each line in the .gitignore excludes a file or set of files that match a pattern.
Example:
# ignore a single file

Config.json -
Step 3: Run the git add .gitignore command
At the initial commit we want basically move from Untracked to Staged, for staging we have to indicate which file we want to move or specify a pattern, as example:
Reference:
http://hermit.no/how-to-find-the-best-gitignore-for-visual-studio-and-azure-devops/ https://geohernandez.net/how-to-add-an-existing-repository-into-azure-devops-repo-with-git/

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Sylph
Highly Voted 4 years ago
I think it should be: Add Config.json to the .gitignore file. Run the git add .gitignore command. Run the git commit command.
upvoted 201 times
mjansen
3 days, 12 hours ago
Agreed, Changes to files (in this case .gitignore) should be staged, so git add .gitignore, and then committed.
upvoted 1 times
...
Dalias
3 years, 9 months ago
Got this in 30 June 2021 exam. Scored 800+ followed this answer
upvoted 8 times
rfox321
3 years, 6 months ago
King! Thank you!
upvoted 1 times
...
...
pexonconsulting
4 years ago
same here
upvoted 2 times
...
Kinon4
3 years, 11 months ago
Agree on Sylph's answer
upvoted 2 times
...
...
LeeVee
Highly Voted 4 years ago
Should be 1. Run git add .gitignore 2. Add config.json to the .gitignore 3. Run git commit
upvoted 34 times
lyggwtwtczxnhznebw
3 years, 10 months ago
Agreed. The .gitgnore file will not be created by default, so you need to add it manually
upvoted 3 times
zioalex
3 years, 10 months ago
This is wrong. If you add the file before modifying it you need to re-add later. The correct sequence is: 1. Add config.json to the .gitignore 2. Run git add .gitignore 3. Run git commit
upvoted 22 times
lyggwtwtczxnhznebw
3 years, 10 months ago
I misunderstood. This is the correct answer. Disregard comment below
upvoted 3 times
...
lyggwtwtczxnhznebw
3 years, 10 months ago
This is wrong. git add .gitignore creates the gitignore file. There is no gitignore before running that command, so you cannot add anything to it
upvoted 3 times
celciuz
3 years, 8 months ago
"git add .gitignore" does not auto create the .gitignore file. You will need to manually create the .gitignore file in your project root then run "git add .gitignore" to add it as a newly added git file to be tracked and then to be committed by using git commit
upvoted 9 times
...
...
...
...
virnay1
1 year, 1 month ago
Git add does not create the file but puts it in a staged state
upvoted 1 times
...
...
wahabajasco
Most Recent 2 months, 2 weeks ago
It should be: 1. Manually create the .gitignore file and add the config.json - Add Config.json to the .gitignore file. 2. Run the "git add" command to stage the newly created .gitignore file - Run the git add .gitignore command. 3. Commit the staged changes - Run the git commit command.
upvoted 1 times
...
UrbanRellik
6 months, 1 week ago
1. Git add .gitignore 2. Add config.json to the .gitignore file. 3. git commit
upvoted 2 times
...
megleg
7 months, 2 weeks ago
1. Add config.json to the .gitignore 2. Run git add .gitignore 3. Run git commit
upvoted 1 times
...
vsvaid
1 year, 3 months ago
1. Add config.json 2. Run git add .gitignore 3. Run git commit
upvoted 1 times
...
yana_b
1 year, 6 months ago
Provided answer is correct: https://learn.microsoft.com/en-us/azure/devops/repos/git/ignore-files?view=azure-devops&tabs=visual-studio-2022 Entries in a .gitignore or exclude file have no effect on files that Git already tracks. Git tracks files that you've previously committed. To permanently remove a file from the Git snapshot so that Git no longer tracks it, but without deleting it from the filesystem, run the following commands: git rm --cached <file path> git commit <some message> Then, use a .gitignore or exclude file entry to prevent Git from reporting changes to the file. We do not have the above options amongst the answers => delete & recreate the repo should be the 1st step.
upvoted 2 times
Mattt
6 months, 1 week ago
Correct answer
upvoted 1 times
...
...
xRiot007
1 year, 8 months ago
Answer is : 1. Add the config file to the git ignore file 2. Run git add to add the change to staging 3. Run git commit to commit all staged changes.
upvoted 1 times
...
dipti927
1 year, 10 months ago
Correct Answer : Add Config.json to the .gitignore file. Run the git add .gitignore command. Run the git commit command.
upvoted 2 times
...
Pamban
1 year, 10 months ago
Moderator, please correct these answers. people are paying to these content and many members provide the evidence for the given answer is incorrect...
upvoted 5 times
Mattt
6 months, 1 week ago
The given answer is correct. You have alresdy commited the config file. Your commit stays in the history and config secrets leak to the git history.
upvoted 1 times
Mattt
6 months, 1 week ago
Sorry, we still haven't commited.
upvoted 1 times
...
...
...
randomaccount123
2 years ago
I think some people are getting confused and thinking git add .gitignore will add the file. It doesn't. That will just add the file to the staging area if it already exists. If it doesn't exist you will get an error. You therefore need to add config.json to the file first and then run git add to add it to the staging area. Then obviously once its in the staging area you can the commit it.
upvoted 1 times
...
AKhalid
2 years, 2 months ago
Verified correct answer is : 1-Add Config.json to the .gitignore file. 2-Run the git add .gitignore command. 3-Run the git commit command.
upvoted 2 times
...
Atos
2 years, 7 months ago
"Delete and recreate the repository" - seems extremely harsh. Also it doesn't indicate that config.json was committed. I think we can rule this out. "git reflog expire" - this removes reflog entries, not really relevant. I think we can rule this out. So now just the ordering: 1. Run the git add .gitignore command - This will add the file for us to exclude config.json 2. Add Config.json to the .gitignore file - makes sense adding something in our empty file to exclude. 3. Run the git commit - This will add it to the repository.
upvoted 2 times
randomaccount123
2 years ago
Wrong, git add will not add the file. It will just add it to the staging area if it already exists. If it doesn't you will get an error.
upvoted 1 times
...
...
syu31svc
2 years, 8 months ago
A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. So answer is 1) Add Config.json to the .gitignore file. 2) Run the git add .gitignore command. 3) Run the git commit command.
upvoted 4 times
...
Eltooth
2 years, 11 months ago
Run the git add .gitignore command Add Config.json to the .gitignore file Run the git commit command https://stackoverflow.com/questions/10744305/how-to-create-a-gitignore-file#:~:text=gitignore%20file%20is%20not%20added,commit%20%2Dm%20%22message%22%20.
upvoted 1 times
Eltooth
2 years, 11 months ago
On labing this with Git you cannot run "git add .gitignore" command if the .gitignore file does not exist. So you either manually create the .gitignore file first then add config.json file to it, or follow steps that @Sylph suggests at top of page.
upvoted 3 times
...
...
UnknowMan
2 years, 11 months ago
- Add manualy a gitignore file (git add .gitignore just add a file named .gitignore, is not a build in command) - Add Config.json to the gitignore file - Run git commit
upvoted 1 times
...
aroravibhu
3 years, 3 months ago
1. Git Ignore command. 2. Add Config.json to the .gitignore file. 3. Run the git commit command. Run the git commit command. https://docs.microsoft.com/en-us/azure/devops/repos/git/ignore-files?view=azure-devops&tabs=visual-studio
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago