Every developer should be familiar with this Git commands.

Okay, Git is necessary to keep our project in a safe place. we can also collaborate on a specific project & build something grate things. So that's why a git is a necessary tool for every developer. Today I will show you some useful git commends which will use every moment.

1. Initializes a new Git repository


2. Add file or add all files

git add file_name
git add .

3. Reverts to the last commit & undoes the changes to the local files.

git reset

4. The difference between two commits' files, or between a commit and your current repository, is displayed.

git diff

5. It's used to see how the staging area and working directory are doing.

git status

6. This command is used to commit files to the repository (locally).

git commit -m "message"

7. See the commit history

git log

8. This command is used to display a list of all the machine's local branches.

git branch

9. Download existing code from a remote repository.

git clone

10. To establish a new branch locally, use this command.

git branch branch_name

11. Delete a branch.

git branch -d branch_name

12. To rename current working branch, used to this command

git branch -m new_branch_name

13. The provided branch is merged into the current functioning branch.

git merge branch_name

14. Switch current branch to another branch.

git checkout branch_name

15. Creating a new branch & switch to the new one.

git checkout -b branch_name

16. Save all commits to the remote repository.

git push <remote> <branch>
git push main branch_name
//check your all remote repository
git remote -v

17. Pull down all the updates rom the remote repository.

git pull remote_name
git pull main

18. Remove a file from the working directory.

git rm file_name

19. It's used to get rid of changes that haven't been committed yet.

git stash

20. Removing Git from a project

If you want to completely remove Git from a project, simply open it, make sure you can see hidden files, then delete the '.git' folder.