Git Git Configuration and Setup 2 β Questions and Answers
Question 1: What does `git config --global alias.st status` accomplish?
- Creates a new Git command called `status`
- Sets `git st` as a shorthand for `git status` (Correct answer)
- Renames the `status` command to `st`
- Adds `status` output to the global log
Correct answer: Sets `git st` as a shorthand for `git status`
This command creates a Git alias so that typing `git st` runs `git status`, saving keystrokes.
Question 2: Which setting controls line-ending conversion when checking out and committing files on Windows?
- core.autocrlf (Correct answer)
- core.lineending
- core.eol
- core.newline
Correct answer: core.autocrlf
The `core.autocrlf` setting controls whether Git automatically converts CRLF line endings on Windows to LF on commit and vice versa on checkout.
Question 3: What is the purpose of a global `.gitignore` file configured with `core.excludesfile`?
- Ignores files in the system Git installation
- Applies ignore rules to all repositories for the current user without modifying each repo's `.gitignore` (Correct answer)
- Overrides local `.gitignore` rules
- Prevents pushes of ignored files
Correct answer: Applies ignore rules to all repositories for the current user without modifying each repo's `.gitignore`
The `core.excludesfile` setting points to a global ignore file that applies to every repository cloned by the user, useful for IDE files and OS-specific artifacts.
Question 4: How do you configure Git to use a proxy for HTTPS connections?
- git config --global http.proxy http://proxy:port (Correct answer)
- git config --global proxy.url http://proxy:port
- git config --global network.proxy http://proxy:port
- git config --global remote.proxy http://proxy:port
Correct answer: git config --global http.proxy http://proxy:port
Setting `http.proxy` in the global Git configuration routes all HTTPS Git operations through the specified proxy server.
Question 5: What does `git config --global push.default current` do?
- Pushes all branches by default
- Pushes the current branch to a remote branch of the same name (Correct answer)
- Sets origin as the default remote
- Prevents pushes to the main branch
Correct answer: Pushes the current branch to a remote branch of the same name
Setting `push.default` to `current` makes `git push` target a remote branch with the same name as the local branch being pushed.
Question 6: Which command initializes a new Git repository in the current directory?
- git new
- git start
- git init (Correct answer)
- git create
Correct answer: git init
The `git init` command creates a new `.git` directory in the current directory, initializing an empty Git repository.
What does `git config --global alias.st status` accomplish?