# Basics

### Git Clone

When you clone a remote git repository, that remote code is copied into your 'Local Repository' and also it is copied into your 'Working Directory' (Staging area is empty for freshly cloned projects).

### Git add

After you modify your local files, to add them to Staging area.

```
git add file1.java file2.java
git add *
```

{% hint style="info" %}
You can add all files with \* ex:- git add \*
{% endhint %}

### Git Commit

To move the currently staged files into local repository. You can also label the current commit with a description.

```
git commit -m 'image compression module'
```

### Git Push

To push your local repository changes to the remote git repository(on remote git server).

```
git push origin master
```

### Git Pull

Git pull will fetch the remote git code (from git server) to the local git repository and also merges those files to your working directory. You will most frequently use 'Git Pull' over 'Git Fetch'.

Git Pull = Git Fetch + Git Merge

```
git pull
```

### Git Fetch

To pull other developers code from the remote git repository to the local repository. Git fetch wont merge these freshly fetched files files into 'Working directory'. Check 'Git Pull'.

```
git fetch origin
```

### Git Merge&#x20;

You want to merge the code which is in the local repository to your working direcotry

You may wonder why will your code in your local repository different to your working directory. This happens when you pull code from the remote repository, that will be moved from remote to local repository and then into your working directory.

```
git merge
```

{% hint style="info" %}
A good tutorial on git merge <https://www.atlassian.com/git/tutorials/using-branches/git-merge>
{% endhint %}


---

# 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://www.git-help.com/basics-1.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.
