What is GIT

Git is a version control system that was developed by Linus Torvalds in 2005. It is a distributed version control system, which means that the source code and history are stored on every developer's computer. It helps developers to keep track of the changes made to a codebase, allowing them to work collaboratively on a project, manage versioning, and roll back changes if necessary.


Here are some of the commonly used Git commands with explanation:


  1. 1. git init: Initializes a new Git repository in the current directory. It creates a hidden .git folder that stores all the metadata and history of the repository.


  2. 2. git clone [repository URL]: Clones an existing repository from a remote server to your local machine.


  3. 3. git add [file]: Adds a file to the staging area, which is a place where you can prepare files to be committed.


  4. 4. git commit -m "message" : Commits changes to the repository with a descriptive message. This message should explain the changes made to the codebase.


  5. 5. git push origin [branch]: Pushes changes from the local repository to a remote repository on a specific branch.


  6. 6. git pull: Downloads and merges changes from a remote repository to the local repository.


  7. 7. git branch [branch name]: Creates a new branch in the repository.


  8. 8. git checkout [branch name]: Switches to a different branch in the repository.


  9. 9. git merge [branch name]: Merges changes from one branch into another.


  10. 10. git status: Displays the status of the repository, including changes that have not been staged or committed.


  11. 11. git diff: Shows the difference between the current version of the code and the version in the repository.


  12. 12. git log: Displays the commit history for the repository.


These are just a few of the many Git commands available. The more you work with Git, the more you will understand its capabilities and how to use it to manage your projects.