Share

You Must use these Git cmds

Git is important to use for all of us as a web developer or a software developer. Git is the most widely used and powerful version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files.

They would be super useful for accomplishing common tasks like creating or renaming a git branch, removing files, and undoing changes. While other version control systems e.g. CVS, SVN keeps most of their data like commit logs on a central server, every git repository on every computer is a full-fledged repository with complete history and full version tracking abilities, independent of network access or a central server.

However, almost all IDEs support git out of the box and we do not require submitting the git commands manually but it is always good to understand these commands. Below is a list of some git commands to work efficiently with git.

Here are the list of git commands that I most commonly use

  • git init : Initialize a local Git repository
  • git clone repo_url : Clone public repository
  • git clone ssh://git@github.com/[username]/[repository-name].git : Clone private repository
  • git status: Check status
  • git add [file-name] : Add a file to the staging area
  • git add -A : Add all new and changed files to the staging area
  • git commit -m “[commit message]” : Commit changes
  • git rm -r [file-name.txt] : Remove a file (or folder)
  • git branch : List of branches (the asterisk denotes the current branch)
  • git branch -a : List all branches (local and remote)
  • git branch [branch name] : Create a new branch
  • git checkout -b [branch name]: Create a new branch and switch to it
  • git merge [branch name]: Merge a branch into the active branch
  • git merge [source branch] [target branch]: Merge a branch into a target branch
  • git push: Push changes to remote repository (remembered branch)
  • git push origin — delete [branch name] : Delete a remote branch
  • git pull : Update local repository to the newest commit
  • git pull origin [branch name]: Pull changes from remote repository
  • git remote add origin ssh://git@github.com/[username]/[repository-name].git: Add a remote repository
  • git log: View changes
  • git config — global user.name “your_username”: Set globally Username

Thanks for scrolling.