Wanna learn Git but hate tutorials? Here are the only commands you need to know!

Wanna learn Git but hate tutorials? Here are the only commands you need to know!

Git is an important tool for project management because it provides a way to manage and track changes to code and other project files over time. With Git, developers can work independently on the same project without interfering with each other’s changes. It also allows for collaboration among team members, as changes can be easily merged together.

Here’s a list of important Git commands along with a brief description of each:

  1. git init - Initializes a new Git repository. This command creates a new .git directory within the project folder, which tracks changes to the project files.

     $ cd path/to/your/project
     $ git init
    
  2. git clone - Clones an existing Git repository from a remote source (e.g., a GitHub repository) to your local machine.

     $ git clone https://github.com/WRITE_USERNAME HERE /repo.git
    
  3. git add - Adds one or more files to the staging area, preparing them to be committed.

     $ git add path/to/file
    
  4. git commit - Commits changes to the Git repository, which creates a new version of the project. Commits should always have a descriptive message.

     $ git commit -m "Add a descriptive message here"
    
  5. git status - Shows the status of the repository, including any changes that have been made but not yet staged or committed.

     $ git status
    
  6. git log - Shows the history of all commits made to the repository.

     $ git log
    
  7. git diff - Shows the differences between two versions of a file.

     $ git diff path/to/file
    
  8. git branch - Manages branches in a Git repository. Branches allow multiple users to work on different aspects of a project simultaneously.

     $ git branch branch_name
    
  9. git checkout - Switches between different branches in a Git repository.

     $ git checkout branch_name
    
  10. git merge - Merges changes from one branch into another.

    $ git merge branch_name
    
  11. git push - Pushes changes from a local repository to a remote repository (e.g., GitHub)

    $ git push origin branch_name
    
  12. git pull - Pulls changes from a remote repository to a local repository.

    $ git pull
    
  13. git stash - Temporarily saves changes that have not been committed, allowing you to switch to a different branch.

    $ git stash
    
  14. git reset - Resets the repository to a previous state. This command can be used to undo commits or discard changes that have not yet been committed.

    $ git reset --hard HEAD
    
  15. git rm - Deletes a file from the repository and stages the deletion

    $ git rm path/to/file
    

    Conclusion:

    These are the most commonly used Git commands and will be enough to give you a headstart on your learning. There are much more available depending on your specific needs.

    Happy Learning!

    Feel free to message me on my Social accounts for any help:

    linkedin.com/in/arsalan-malik-746913237

    twitter.com/ArsalanYmalik