Most frequently used Git Commands

Git is a popular version control system. It was created by Linus Torvalds in 2005. It is used to track code changes, who made changes and Coding collaboration.

You can download and install it from HERE

Here I will list out commands that will be used in you purpose frequently. Such as how to initialize it, add changes, push to the repository that you have created weather it’s on GitHub, GitLab or any of your own server.

  1. git init: Initializes a new Git repository.
  2. git clone: Clones a repository into a new directory.
  3. git add: Adds changes in the working directory to the staging area.
  4. git commit: Commits the changes in the staging area to the repository.
  5. git status: Shows the status of changes as untracked, modified, or staged.
  6. git log: Displays a log of all commits in the repository.
  7. git branch: Lists existing branches, and can create new branches.
  8. git checkout: Switches branches or restores working tree files.
  9. git merge: Merges changes from one branch into another.
  10. git pull: Fetches changes from a remote repository and merges them into the current branch.
  11. git push: Pushes changes to a remote repository.
  12. git remote: Shows a list of remote repositories.
  13. git fetch: Downloads objects and refs from another repository.
  14. git diff: Shows changes between commits, commit and working tree, etc.
  15. git reset: Resets the current HEAD to a specified state.
  16. git revert: Creates a new commit that undoes a previous commit.
  17. git stash: Temporarily saves changes that haven’t been committed.
  18. git tag: Creates, lists, or deletes tags.
  19. git config: Sets configuration values for your user name, email, and more.
  20. git remote add: Adds a remote repository.

These are just some of the basic and commonly used Git commands. Git has a rich set of commands, and you can explore more options and features based on your specific needs. You can access the Git documentation for detailed information on each command (git help <command>).

Examples of each command

Examples for each of the Git commands mentioned:

  1. git init
   git init
  1. git clone
   git clone
  1. git add
   git add file.txt
  1. git commit
   git commit -m "Commit message"
  1. git status
   git status
  1. git log
   git log
  1. git branch
   git branch feature_branch
  1. git checkout
   git checkout feature_branch
  1. git merge
   git merge feature_branch
  1. git pull
   git pull origin master
  1. git push git push origin master
  2. git remote git remote -v
  3. git fetch git fetch origin
  4. git diff git diff HEAD
  5. git reset git reset --hard HEAD^
  6. git revert git revert <commit-hash>
  7. git stash git stash
  8. git tag git tag v1.0.0
  9. git config git config --global "Your Name" git config --global ""
  10. git remote add
    bash git remote add upstream

Leave a comment

Your email address will not be published. Required fields are marked *