Git Stages (Basic Git Commands - Handle Stages)

Remote repositories such as GitLab, GitLab hub, Azure Repos, Bitbucket, they are only cloud providers. They are giving you space to store your source code. Nowadays they have started adding more features that you can manage your git directly from the portal

 

Git Bash
Shell that I will be employing to collaborate with Git.
Therefore, git bash an uncommonly extensive command set that enables users to manage all aspects of their workflow.

 

Working  Directory (PWD - Parent Working Directory)
PWD has nothing to do with git if I add any files to it, and if we delete any files, git has nothing to do with it. No one is tracking any deletion or anything as such.

 

 

INIT Git Repository
Go to PWD at your local and run

This will make your working directory- with default branch ‘main’ as local

What makes this directory a local git repository is the hidden file.

We can see a local git repository directory

Inside this git repository, you can see multiple files. You can see everything related to git. 

  • So these are the files which is basically managing your complete local git repository. Starting with head config has all the configuration information hooks.
  • It will have all the pre hooks, post hooks and different different hooks which we use.
  • At later stages, When you start committing your changes adding files, you will see the history and everything as well.

 

if moving to another system
So along with your source code, you need to make sure that you copy this target file. Also, if you want to start from the same stage where you left your task. So you need to make sure you have your target file also copied to the other system.

 

 

Create an HTML file using CLI

 

Read you file in Read only Mode

 

 

 

STATUS CHECK of your Working Directory at local

It will help you view untracked and tracked files if you want to view and tracked files or staged files use Git Status

 

 

MOVE FILE/ADD from Working director to stating area
git add operation which will basically add the file into the staging area.

Now check status again

Git is still not tracking that file for you. Git will not bother even after from the staging area if you delete that file. Can use variation onf Git Add

  • git add .
  • git add /
  • git add *.css

 

 

GIT COMMIT
This distributed version control basically manages its own databases in the back end.  And if you want to update the information like whatever files you have added and the file which is there in the staging area, if you want that file to be part of the git local database, then you will do a git commit.

When you do a git commit, git will update those information in the local Git repository.

Once that gets added into a local git repository and later when you do any modification or deletion with that file, git will start tracking that file and git will start tracking those changes for you.

 

commit message:  this message is very much required. Without this message, you cannot commit your changes.

One file changed, one file inserted.

Check status again

 


See All your commits so far

This isn't my first time committing to my local git repository. It extracted the details from my previous local repository. In your situation, you won't be able to commit without having this essential information from the user Name and the user's email ID. -  All changes Were pointing towards master branch.

The details were taken from my previous local repository. In your situation, it will prevent you from committing if you lack these two pieces of information from the user.Name and the user's email ID.

 

Add User name and User email id if using Git for the First Time

 

Verify User Detail

 

If I make any changes to this specific file, git will begin tracking that information. If you make any modifications or deletions to this file, git will prompt you to recommit.

 

 


Related Question