Git Configuration Flashcards

1
Q

Q: How do you set a global username in Git?

A

A: Use git config –global user.name “Your Name”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Q: How do you set a global email in Git?

A

A: Use git config –global user.email “your_email@example.com”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Q: What is the purpose of .gitconfig?

A

A: It stores configuration settings for Git, either globally or locally for a specific repository.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q: How do you view all global Git configurations?

A

A: Use git config –list –global.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q: How do you view all local Git configurations for a repository?

A

A: Use git config –list –local.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q: What is the command to edit the global Git configuration file?

A

A: Use git config –global –edit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q: How do you configure Git to use a specific text editor globally?

A

A: Use git config –global core.editor “editor_command” (e.g., nano, vim, code).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: How do you configure Git to use a specific merge tool?

A

A: Use git config –global merge.tool “tool_name”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Q: What does core.autocrlf do in Git configuration?

A

A: It ensures consistent line endings across different operating systems. Use true for Windows or input for Unix-based systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Q: How do you set the default branch name for new repositories?

A

A: Use git config –global init.defaultBranch main.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Q: What does core.ignorecase configure?

A

A: It determines whether Git is case-sensitive when tracking file names. Set to true to ignore case differences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Q: How do you enable colored output in Git?

A

A: Use git config –global color.ui auto.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Q: How do you configure Git to cache your credentials?

A

A: Use git config –global credential.helper cache.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Q: How do you configure Git to remember your credentials permanently?

A

A: Use git config –global credential.helper store.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Q: What does push.default configure in Git?

A

A: It sets the default behavior for git push. Common values are simple, current, and matching.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Q: How do you set a custom alias for a Git command?

A

A: Use git config –global alias.alias_name “command”, e.g., git config –global alias.co “checkout”.

17
Q

Q: How do you enable verbose output for Git commands by default?

A

A: Use git config –global advice.statusHints true.

18
Q

Q: How do you configure Git to sign commits with a GPG key?

A

A: Use git config –global user.signingkey “your_gpg_key_id” and git config –global commit.gpgSign true.

19
Q

Q: How do you configure a proxy for Git?

A

A: Use git config –global http.proxy “http://proxy_url:port” or git config –global https.proxy “https://proxy_url:port”.

20
Q

Q: How do you remove a Git configuration setting?

A

A: Use git config –global –unset key, e.g., git config –global –unset user.email.

21
Q

Q: How do you specify a different SSH key for Git?

A

A: Edit or add a Host entry in the ~/.ssh/config file to specify the key for specific repositories.

22
Q

Q: How do you disable SSL verification in Git (not recommended)?

A

A: Use git config –global http.sslVerify false.

23
Q

Q: How do you set a per-repository Git email address?

A

A: Use git config user.email “repo_specific_email@example.com” within the repository directory.

24
Q

Q: What is the command to check the current Git version?

A

A: Use git –version.

25
Q

Q: How do you configure a template directory for Git commit messages?

A

A: Use git config –global commit.template “/path/to/template/file”.