> For the complete documentation index, see [llms.txt](https://asafahmadov.gitbook.io/cloud-and-devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://asafahmadov.gitbook.io/cloud-and-devops/devops-bootcamp/version-control-with-git/working-with-git.md).

# Working with Git

When working with files in Git, it is important to know the different statuses of the file can have. There are three stages that codes go through.&#x20;

If I create a new file or make changes to an existing file these changes will be in my **working directory**. The working area, in brief, is the files that are not in the staging area. They're not handled by Git. They're kind of just in our local directory. They can also be called <mark style="color:red;">untracked files.</mark> The working area is like your <mark style="color:green;">scratch space</mark>, it's where you can add new content, you can modify delete content, if the content that you modify or delete is in your repository you don't have to worry about losing your work.

The **staging area**, that's what files are going to be a part of your next commit. It's how Git knows what is going to change between the current commit and the next one. A staging area isn't empty. It is an exact copy of the latest commit. When files are added or removed from the staging area git knows because the hash (SHA1) of your files is different from the ones in your repository.

Everything from staging are can be committed to my **Local repository**. The repository contains all of your commits. And the commit is a snapshot of what your working and staging area look like at the time of the commit. It's in your .git directory. And that's all of the files in your repository, they're stored away safely, you can continue to make changes as you work and you can always check out a fresh copy if you need one.

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FYQ9AWtZdPneaMwwzGQIa%2Fimage.png?alt=media\&token=2d836464-9c39-4820-9a3c-2a38e28e8f6a)

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FnWKmJ86tm2kdsf7e989z%2FScreen%20Shot%202022-05-11%20at%2023.17.39.png?alt=media\&token=90347bb6-7734-4ad9-8c46-b86d06f7c90c)

```
mkdir "Gitlab Project"
cd Gitlab\ Projects/
git clone git@gitlab.com:asefehmed1/first-project.git #
```

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FJGLdRGdwl3NkuQCMEnJi%2Fimage.png?alt=media\&token=fdb462cf-b51a-42d7-b691-d213fe90806e)

```bash
git status
```

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FYenCYfkU0FW3SNDoxsXF%2Fimage.png?alt=media\&token=f0034f19-f124-4459-826d-79a1a690eb52)

```bash
git add . # Move all files in the working directory to the staging area 
```

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FOb8BixoAhKSUxaVwtay3%2Fimage.png?alt=media\&token=c2306bdd-3bcb-45e2-98b6-20c960a76e7a)

```bash
git commit # To save our changes in your local repository.
```

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2Fj6YW3y8J9x6f07GjvRkZ%2Fimage.png?alt=media\&token=3addf9b9-725d-4a10-9b93-f0b906ba1081)

```
git log
```

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2Fcw7xdlSPRR3ZYYZvdVT2%2Fimage.png?alt=media\&token=877ea6ad-1d6c-41de-ac0f-219d6b38ac51)

```bash
git push # Sending our changes to the remote Gitserver
```

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FYrDoKgEVXK7PF0uOLn3J%2Fimage.png?alt=media\&token=8d771000-8cb4-46e4-8fe4-06eac881451b)
