Git Commands and Their Definitions
1. git clone <repository_url>
Clones a remote GitHub repository to your local machine.
2. git add <filename>
Tracks changes made to a specific file and stages it for commit.
3. git add .
Tracks all untracked and modified files in the repository.
4. git status
Displays the current status of the working directory and staging area, showing tracked and
untracked changes.
5. git commit -m "commit message"
Commits the staged changes locally with a message describing the changes.
6. git init
Initializes a new Git repository in the current folder.
7. git remote add origin <repository_url>
Connects the local repository with a remote GitHub repository.
8. git branch -M main
Renames the current branch to "main" (often used after initialization).
9. git push -u origin main
Pushes changes to the remote repository and sets "origin main" as the default upstream branch.
10. git remote -v
Displays the remote repositories linked to the local repository.
11. git branch
Lists all branches in the repository.
12. git checkout -b <new_branch>
Creates a new branch and switches to it.
13. git checkout <branch_name>
Switches to an existing branch.
14. git diff <branch_name>
Shows the differences between the current branch and the specified branch.
15. git pull
Fetches and merges changes from the remote repository into the local branch.
16. git branch -d <branch_name>
Deletes a branch locally.
17. git commit -am "commit message"
Stages and commits all modified files in a single command.
18. git merge <feature_branch>
Merges the specified feature branch into the current branch.
19. git reset <filename>
Unstages a file while keeping the changes in the working directory.
20. git reset HEAD
Unstages all staged files while keeping their modifications.
21. git log
Shows the commit history of the repository.
22. git reset --hard
Resets the working directory and staging area to the last committed state, discarding all changes.