srngx
Dec 20, 2024
Git is a Distributed Version Control System that mainly used for Source code management by developers.
Git basically divides your code into three part.
Working Area is your state of code before running the git add
command.
The files in here also known as "untracked files".
To add the files into git you do git add
and they moved to
staging area
.
Here your code gets the stage (Pun Intended).
Before finalizing your code into production i.e. 'commit' you make required changes and after making sure
your code is ready to go into production you run git commit
command.
which is basically telling git this is a final changes with the special stamp of "commit hash".
Then If you want you can push your code into remote repository sitting onto the cloud waiting to be forked and contributed by peoples across the glob.
Commands | Description |
---|---|
git add |
To add code into git |
git commit |
To commit changes |
git push |
To upload your code into remote repo |
git pull |
To download latest changes from remote to your local |
git fetch |
Fetching Metadata and logs from remote |
Git Provide "Branches" which are nothing but a way to seperate your code into different version so you can later integrate your features and bugfixes into production once they finished peacefully in their own isolated places.
There are well known three branches people generally creates:
Some people also like to create their own custom branches like `alpha, beta, stable` etc i.e. according to release state.
git branch -a
List all available branches git checkout -b
Create and switch to the new branch git checkout
To switch to different branch