Skip to main content

Git - Command Reference

Common Commands

TaskCommand
Add changes to staginggit add .
Commit changesgit commit -m "Update"
Pull code from a branchgit pull origin master
Push code to a branchgit push origin master

Branch Commands

TaskCommand
List branchesgit branch
Create a new branchgit branch <new-branch-name>
Switch to a branchgit checkout <branch-name>
Delete a branchgit branch -d <branch-name>

Merging Branches

TaskCommand
Merge a branch into another branchgit merge <source-branch>
Commit itgit commit -m "Merge feature-branch into main"

Creating and Pushing a New Branch Based on Release

TaskCommand
Fetch origingit fetch origin
Create new feature branchgit checkout -b new-feature-branch origin/release
Push feature branchgit push origin new-feature-branch

Creating and Pushing a Daily Branch Based on Release

TaskCommand
Create and switch to daily branchgit checkout -b daily-<date>-gr origin/release
Push daily branchgit push origin daily-<date>-gr

Code Library

TaskCommand
Delete a remote branchgit push origin --delete <branch-name>

Submodule Commands

TaskCommand
Initialize submodulesgit submodule init
Update submodulesgit submodule update

Revert a commit

  1. git log to check log
  2. git reset --hard HEAD^
  3. git push origin <branch> --force

example

git log
git reset --hard d37c4bb36ebbb03e0f3beccb72418e153bf7b367
git push origin feat-country-comparison-gr-2024-3-20 --force