Revanth Vermareddy

Git Commands to Remember

1 minutes (265 words)
git-icon

🔗Git

  1. Here are some common Git commands

    • git init: creates a new Git repository
    • git clone <url>: clone a remote Git repository to a local machine
    • git add <file>: add a file to the staging area
    • git add .: add all changes to the staging area
    • git commit -m "message": commit changes to the repository with a message
    • git push: push committed changes to a remote repository
    • git pull: pull changes from a remote repository to a local repository
    • git status: display the current status of the repository
    • git log: display the commit history
    • git branch: list all the branches in the repository
    • git checkout <branch>: switch to a different branch
    • git merge <branch>: merge changes from a different branch into the current branch
    • git diff: display the differences between two commits or branches
  2. Here are some git stash commands

    • git stash: stashes changes in the working directory, saving them for later use
    • git stash list: lists all stashes in the repository
    • git stash apply: applies the most recently created stash to the current branch
    • git stash apply <stash>: applies a specific stash to the current branch
    • git stash pop: applies the most recently created stash to the current branch and removes it from the stash list
    • git stash pop <stash>: applies a specific stash to the current branch and removes it from the stash list
    • git stash drop: removes the most recently created stash from the stash list
    • git stash drop <stash>: removes a specific stash from the stash list
    • git stash clear: removes all stashes from the stash list

Tags: #git