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.

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 untracked files. The working area is like your scratch space, 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.

mkdir "Gitlab Project"
cd Gitlab\ Projects/
git clone git@gitlab.com:asefehmed1/first-project.git #
git status
git add . # Move all files in the working directory to the staging area 
git commit # To save our changes in your local repository.
git log
git push # Sending our changes to the remote Gitserver

Last updated