10 Everyday Git Commands

10 Everyday Git Commands

Git is most popular version control system in the world and almost every software engineer uses it on daily bases. Sure there is tons of GUIs which helps people to start using Git, but to do it properly you have to learn these 10 everyday commands. It might look complicated, but trust me it’s way easier to learn these 10 than to setup some 3rd party tool on super restrictive laptop, which your big client asks you to work on.

  1. git clone – used to clone a repository to a new location. For example: “git clone ssh://git@your-remote-repository“. More details.
  2. git status – oh you will be using this one a lot, it tells you which changes have been staged, which haven’t, and which files are not tracked by Git.
  3. git branch – used to list, create or delete branches. For example: “git branch my-branch” – will create new branch. More details.
  4. git checkout – Used to switch branches or restore working tree files, full syntax: “git checkout <branch-name>“, example: “git checkout develop“. Also really useful one is: “git checkout -b <branch-name>” – by adding “-b” a new branch to be created for you. More details.
  5. git add – will add file/files to Git index. For example: “git add .” – adds all files to the index, details.
  6. git commit – used to record applied changes to the repository. Usually will be used as: “git commit -m ‘message’“. “-m” – adds commit message. More details.
  7. git push – pushes your local changes to remote repository, full syntax: “git push <remote> <branch-name>“, example: “git push origin develop“. More details.
  8. git reset – resets current “HEAD” to specified state. Mostly used to revert changes. For example: “git reset HEAD~1” – reverts last commit. Details.
  9. git init – this command creates a new git repository or reinitialize an existing. Details.
  10. git stash – puts your changes into your working directory without commit so you can access them later. Details.

Add Comment

Your email address will not be published. Required fields are marked *