DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 968,547 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Abu Jaid
Abu Jaid

Posted on

Basic git commands every web developer should know

git init

The git init command is used to initialize a new git repository. this command is used to set up a new repository.

git status

This command can be used to see which files have been modified, which files are new and which files are not tracked by git.

git add

The git add command is used to add files to the staging area.

git commit -m "commit message"

The git commit -m "message" command is used to commit changes to a git repository.

git push

The git push command is used to push commits from a local repository to a remote repository.

git pull

This git pull command is used to fetch and download content from a remote repository and update the local repository to match the remote.

git branch

The git branch command is used to create, list, rename and delete the branches.

git checkout branch

The git branch <branch name> command is used to switch one branch to another branch in a git repository.

git merge

The git merge command is used to join two or more development branches.

deleting a remote branch

The git push origin --delete <branch> is used to delete the remote branch.

deleting a local branch

The git branch --delete <branch> is used to delete the local branch.

squash all git commits into one

to squash all the git commits into one commit.

  1. git rebase -i HEAD~4 (4 is the number of commits to a particular branch)
  2. git push origin <branch_name> --force

git log by the amount

git log -2 (the following command will display only the 3 most recent commits.)

exit git log

The q or z is used to quit from logs.

exit from git vim editor

The :wq is used to save the change. and :wq! is used for no changes to save.

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.