Most Used Git & GitHub Commands

ยท

2 min read

Git Commands:

  • git init: Initializes a new Git repository in the current directory.
  • git clone : Creates a local copy of a remote repository.
  • git add : Adds a file to the staging area.
  • git commit -m "": Records the staged changes to the repository with a descriptive message.
  • git status: Shows the status of the working directory and staging area.
  • git log: Displays the commit history of the repository.
  • git branch: Lists all the branches in the repository.
  • git checkout : Switches to the specified branch.
  • git merge : Merges the specified branch into the current branch.
  • git pull: Fetches changes from a remote repository and merges them into the current branch.
  • git push: Pushes the local commits to a remote repository.
  • git remote add : Adds a remote repository.

GitHub Commands:

  • git remote -v: Lists the remote repositories associated with the current Git repository.
  • git push -u : Sets up tracking of the specified branch on a remote repository.
  • git pull : Fetches changes from a remote repository and merges them into the current branch.
  • git branch -d : Deletes a branch.
  • git checkout -b : Creates a new branch and switches to it.
  • git fork: Creates a copy of a remote repository under your GitHub account.
  • git pull-request: Creates a pull request on GitHub for code review and collaboration.
  • git stash: Temporarily saves changes that are not ready to be committed.
  • git stash apply: Restores the most recently stashed changes.
  • git tag : Creates a new tag for a specific commit.
  • git submodule: Manages Git submodules within a repository.
ย