DEV Community

Kaushik V
Kaushik V

Posted on • Edited on

Frequently used Git commands

Here are some commonly used Git commands for someone who is learning about version control systems.

  1. Cloning a Repository
    git clone – Copies a remote repository to the local machine.

  2. Staging Changes
    git add – Stages a specific file for commit.
    git add . – Stages all modified and new files.

  3. Committing Changes
    git commit -m "commit message" – Saves the staged changes to the local repository with a message.

  4. Pushing Changes to a Remote repository
    git push – Used for Uploading the committed changes to the remote repository.

  5. Restoring Staged changes
    git restore --staged – Removes a file from the staging area but keeps changes in the working directory.

  6. View the Commit history
    git log – Displays commit history with specific details like author name, date of modification and messages for identification.

  7. creating and handling the branches in a repository
    git branch - Lists all branches in the repository.
    git branch - Creates a new branch.
    git checkout - Switches to an existing branch.

Top comments (0)