# Modify-stage-commit

## Modifying existing file&#x20;

Let us modify the contents of the first file and see how Git tracks the changes. Make some simple changes to the contents of the first file, save it and then run status command

```bash
git status
```

```
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   hello.txt

no changes added to commit (use "git add" and/or "git commit -a")
```

{% hint style="info" %}
The file is modified but not yet staged for commit!
{% endhint %}

### Staging the file(s)&#x20;

We must not try to commit without staging the files, We use the same command to add the files to the staging area as before!

{% hint style="danger" %}
&#x20;This commit will not be successful&#x20;
{% endhint %}

```bash
git commit -m "hello modified"
```

```
On branch master
Changes not staged for commit:
        modified:   hello.txt

no changes added to commit
```

First add the modified files to the staging area and then commit

```bash
 git add .
```

```
git status

On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   hello.txt
```

{% hint style="success" %}
This commit will be successful&#x20;
{% endhint %}

```bash
git commit -m "hello modified"
```

```
[master 4d7bd7f] hello modified
 1 file changed, 1 insertion(+), 1 deletion(-)
```
