Basic Git Commands

  1. git init: Initializes a new Git repository.
  2. git clone <repository-url>: Clones an existing repository from a URL to your local machine.
  3. git status: Shows the status of changes in the working directory.
  4. git add <file>: Stages changes in a file for the next commit.
  5. git commit -m "commit message": Commits the staged changes with a message.
  6. git push: Pushes commits from your local repository to the remote repository.
  7. git pull: Fetches and merges changes from the remote repository to your local branch.
  8. git branch: Lists, creates, or deletes branches.
  9. git checkout <branch-name>: Switches to a different branch.
  10. git merge <branch-name>: Merges the specified branch into the current branch.
  11. git log: Displays the commit history for the current branch.
  12. git remote -v: Shows the remote repositories linked to your local repository.
  13. git reset <file>: Unstages a file, keeping the changes in the working directory.
  14. git diff: Shows the differences between the working directory and the staged changes.

Leave a Reply

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