What does the git gc command do?

What does the git gc command do?

a) Optimizes the Git repository by cleaning up unnecessary files and compressing objects
b) Generates a commit graph
c) Commits all changes automatically
d) Deletes all untracked files

Answer:

a) Optimizes the Git repository by cleaning up unnecessary files and compressing objects

Explanation:

The git gc command performs garbage collection in a Git repository, optimizing it by cleaning up unnecessary files and compressing loose objects. It helps reduce the size of the repository and improves performance.

For example, Git might run git gc automatically after a certain number of commits, but you can also run it manually to clean up the repository.

This is important for maintaining a healthy repository, especially after many changes or merges.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top