# GIT

<figure><img src="/files/pg3qUu6soLoRK7qAIpbY" alt=""><figcaption><p><a href="https://xkcd.com/1597/">XKCD</a></p></figcaption></figure>

<table data-header-hidden><thead><tr><th width="241"></th><th></th></tr></thead><tbody><tr><td><strong>Command</strong></td><td><strong>Function</strong></td></tr><tr><td>git init</td><td>Create empty Git repo in specified directory. Run with no arguments to initialize the current directory as a git repository.</td></tr><tr><td>git clone</td><td>Clone repo located at onto local machine. Original repo can be located on the local filesystem or on a remote machine via HTTP or SSH.</td></tr><tr><td>git config user. name</td><td>Define author name to be used for all commits in current repo. Devs commonly use --global flag to set config options for current user.</td></tr><tr><td>git add</td><td>Stage all changes in for the next commit. Replace with a to change a specific file.</td></tr><tr><td>git commit -m ""</td><td>Commit the staged snapshot, but instead of launching a text editor, use as the commit message.</td></tr><tr><td>git status</td><td>List which files are staged, unstaged, and untracked.</td></tr><tr><td>git log</td><td>Display the entire commit history using the default format. For customization see additional options.</td></tr><tr><td>git diff</td><td>Show unstaged changes between your index and working directory.</td></tr><tr><td>git remote add</td><td>Create a new connection to a remote repo. After adding a remote, you can use as a shortcut for in other commands.</td></tr><tr><td>git fetch</td><td>Fetches a specific , from the repo. Leave off to fetch all remote refs.</td></tr><tr><td>git pull</td><td>Fetch the specified remote's copy of current branch and immediately merge it into the local copy.</td></tr><tr><td>git push</td><td>Push the branch to , along with necessary commits and objects. Creates named branch in the remote repo if it doesn't exist.</td></tr><tr><td>git revert</td><td>Create new commit that undoes all of the changes made in , then apply it to the current branch.</td></tr><tr><td>git reset</td><td>Remove from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes.</td></tr><tr><td>git clean -n</td><td>Shows which files would be removed from working directory. Use the -f flag in place of the -n flag to execute the clean.</td></tr><tr><td>git diff HEAD</td><td>Show difference between working directory and last commit.</td></tr><tr><td>git diff --cached</td><td>Show difference between staged changes and last commit</td></tr><tr><td><strong>GIT RESET</strong></td><td></td></tr><tr><td>git reset</td><td>Reset staging area to match most recent commit, but leave the working directory unchanged.</td></tr><tr><td>git reset --hard</td><td>Reset staging area and working directory to match most recent commit and overwrites all changes in the working directory.</td></tr><tr><td>git reset</td><td>Move the current branch tip backward to , reset the staging area to match, but leave the working directory alone.</td></tr><tr><td>git reset --hard</td><td>Same as previous, but resets both the staging area &#x26; working directory to match. Deletes uncommitted changes, and all commits after .</td></tr><tr><td><strong>GIT REBASE</strong></td><td></td></tr><tr><td>git rebase -i</td><td>Interactively rebase current branch onto . Launches editor to enter commands for how each commit will be transferred to the new base.</td></tr><tr><td><strong>GIT PULL</strong></td><td></td></tr><tr><td>git pull --rebase</td><td>Fetch the remote's copy of current branch and rebases it into the local copy. Uses git rebase instead of merge to integrate the branches.</td></tr><tr><td><strong>GIT PUSH</strong></td><td></td></tr><tr><td>git push --force</td><td>Forces the git push even if it results in a non-fast-forward merge. Do not use the --force flag unless you're absolutely sure you know what you're doing.</td></tr><tr><td>git push --all</td><td>Push all of your local branches to the specified remote.</td></tr><tr><td>git push --tags</td><td>Tags aren't automatically pushed when you push a branch or use the --all flag. The --tags flag sends all of your local tags to the remote repo.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.thedatascienceinterviewproject.com/ml-ops/git.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
