Logo

Do you have a project in your mind? Get in touch with me easily for inquiries, support, or collaboration.

Contact Us

  • +91 82009 10548
  • info@gaurangdangi.com

Subscribe

Stay informed and connected with our website's newsletter – your source for exclusive updates, news, and insights.

Git Basic Commands

Git Basic Commands

Git Basic Commands

Git is a powerful and widely used version control system that helps you manage and track changes to your codebase.

Here are some basic Git commands to get you started:

  1. Initialize a Git Repository:
    • To start using Git in a directory, you need to initialize a Git repository.
      git init
  2. Clone a Repository:
    • To copy an existing Git repository from a remote source (like GitHub) to your local machine:
      git clone
  3. Check Status:
    • To see the status of your working directory, showing which files have changed and which files are staged for commit:
      git status
  4. Add Files to Staging Area:
    • To stage changes for the next commit:
      git add
    • You can also use git add . to stage all changes.
  5. Commit Changes:
    • To commit your staged changes with a commit message:
      git commit -m “Your commit message here”
  6. View Commit History:
    • To see a list of all commits in the current branch:
      git log
  7. Create a Branch:
    • To create a new branch:
      git branch
  8. Switch to a Branch:
    • To switch to a different branch:
      git checkout
    • Or, in newer Git versions:
      git switch
  9. Merge Branches:
    • To merge changes from one branch into another:
      git merge
  10. Pull from a Remote Repository:
    • To fetch and merge changes from a remote repository:
      git pull
  11. Push to a Remote Repository:
    • To push your local commits to a remote repository:
      git push
  12. Update the Remote Repository:
    • To update your local repository with changes from the remote repository:
      git fetch
  13. Discard Changes in Working Directory:
    • To discard changes in your working directory for a specific file:
      git checkout —
  14. Discard Changes in Staging Area:
    • To unstage changes for a specific file:
      git reset HEAD
  15. Undo the Last Commit:
    • To undo the last commit while keeping the changes in your working directory:
      git reset HEAD~1

These are some of the most basic Git commands, and Git offers a wide range of functionality for version control and collaboration. Learning Git takes practice, so don’t hesitate to explore more advanced commands and concepts as you become more comfortable with the basics.

Gaurang Dangi

Hi, my name is Gaurang Dangi and I began using WordPress when it first began. I’ve spent most of my waking hours for the last six years designing, programming and operating Laravel and CodeIgnater websites.