Skip to content

Instantly share code, notes, and snippets.

@codewithmanas
Created March 17, 2023 07:28
Show Gist options
  • Save codewithmanas/caa02633ee15d5c01000ee0504f3cc37 to your computer and use it in GitHub Desktop.
Save codewithmanas/caa02633ee15d5c01000ee0504f3cc37 to your computer and use it in GitHub Desktop.
10 basic Git commands that every beginner should know.
  1. git init: This command initializes a new Git repository in the current directory.

  2. git add: This command adds changes to the staging area. You can specify individual files or use . to add all changes. git add <file name> (for a specific file) or git add . (for all files).

  3. git commit: This command commits changes to the repository. You can add a message with the-m flag, like this: git commit -m "Commit message".

  4. git status: This command shows the status of your repository, including which files have been modified and which are staged for commit.

  5. git log: This command shows the commit history of the repository, including who made each commit, when, and the commit message.

  6. git checkout: This command allows you to switch between branches or restore a file to a previous version. You can also use it to create a new branch.

    `git checkout -b <new_branch>` (creates a new branch if not exist and switches to a new branch)
    
    `git checkout <existed_branch>` (if the branch already exists)
    
  7. git pull: This command pulls changes from a remote repository into your local repository.

  8. git push: This command pushes changes from your local repository to a remote repository.

  9. git branch: This command shows the current branches in your repository. You can use it to create a new branch or delete an existing one.

  10. git clone: This command clones a remote repository onto your local machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment