DEV Community

snehaup1997
snehaup1997

Posted on • Edited on

Git-it!

Git is a version control system that developers use all over the world. It helps you track different versions of your code and collaborate with other developers.

If you can read only one chapter to get going with Git, you've come to the right place. This blog includes all the fundamental commands that cover most of the tasks you will be doing with Git. Once you finish reading this, you will be capable of setting up and initializing a repository, tracking files, and making commits.

  • git clone [repo_url]:
    Creates a copy of a remote Git repository on your local machine.

  • git init:
    Creates an empty Git repository or reinitializes an existing one

  • git add [name_of_modified_file] or git add . :
    The specified file or all files in case of a dot are stages for commit

  • git commit -m "your commit message":
    Commits the staged changes with the mentioned message.

  • git checkout [your_branch_name_goes_here]:
    Switches to the specified different branch.

  • git status:
    Shows the status of your working directory. This including changes and untracked files.

  • git pull:
    Merged latest changes from a remote repo into the current branch.

  • git push:
    Pushes your local commits to a remote repository.

  • git log:
    Displays a log of all commits in the current branch.

  • git branch:
    Lists all branches in your repository and highlights the current one.

  • git merge [branch_name]:
    Merges changes from one branch into another.

  • git stash:
    It temporarily saves the changes that are not ready to be committed yet

  • git diff [file]:
    Enlists differences between working directory & last commit.

  • git remote add [name] [repository_url]:
    Adds a remote repository with a specified name.

Top comments (0)