12 Useful git commands for Beginners

12 Useful git commands for Beginners
Beginners

Git is a powerful version control system used for tracking changes in a file or directory during any software development process.

The following commands will help you to use git in your next software development project:

  1. git init  - to initialize a new git repository.
  2. git add .  - adds all the files and folders in the current to the staging area to start tracking changes.
  3. git commit -m ‘a short message’  - creates a snapshot in the .git directory and starts tracking.
  4. git status  - to check the status of your files.
  5. git rm <file name>  - to remove a file from being tracked.
  6. git clone <remote repository url>  - downloads a copy of the remote repository.
  7. git remote add origin <remote repository url>  - you add a remote repository to your local repo and push changes to the remote repo.
  8. git checkout -b <new branch name>  - creates a new branch and switches to the new branch.
  9. git switch <branch name>  - to switch into a different existing branch.
  10. git merge <branch to merge>  - to merge changes from a different into the current branch.
  11. git pull  - update the local version of a repository from a remote.
  12. git push origin <branch name>  - to push local changes to the remote git repository.

Additional commands:

13.  git log  - to review and read a history of everything that happens to a repository.

14.  git help <verb> - to get the comprehensive manual page help for any of the Git commands.

To know more about git, please check out https://git-scm.com/

Read more