Following are the most used git commands which covers 90% of our work.
git clone <repository link>
- Clones git repository
git branch
- Displays all the local branches
git status
- Displays files which are modified, added, or deleted
git checkout <branch name>
- Switches to the given branch
git checkout -b <branch name>
- Creates a new branch from current branch
git add <file path>
- Stages given file(s)
git commit -m <message>
- Commits the staged files with the message
git pull origin <branch name>
- Pulls from remote repository into current branch
git push origin <branch name>
- Pushes to the linked remote repository
git push -u origin <branch name>
- Creates a new remote branch from local branch and pushes
git fetch
- Gets all the remote branches
git log
- Displays entire commit history
git cherry-pick <commit hash>
- Merges given commit into current branch
git merge <branch name>
- Merges given branch into current branch
git reset --hard commit <commit hash>
- Resets branch to a given commit in the history
git stash
- Saves uncommitted (both staged and unstaged) changes
git stash pop
- Re-applies saved changes
Top comments (0)