Skip to content

Instantly share code, notes, and snippets.

@hasinur1997
Last active March 14, 2023 06:58
Show Gist options
  • Save hasinur1997/f43ba35fd8adaac01c450d03faad9493 to your computer and use it in GitHub Desktop.
Save hasinur1997/f43ba35fd8adaac01c450d03faad9493 to your computer and use it in GitHub Desktop.
Git commands

Common git commands

git add . ("Add all changes on current branch")

git status ("Display the state of the working directory")

git commit -m "Commit message" ("Added git commit message")

git commit --amend -m "New commit message" ("Changes the recent commit message")

git pull remote_name branch_name ("Pull all latest changes from remote branch")

git push remote_name branch_name ("Push local changes to remote")

git pull remote_name branch_name --rebase ("Rebase flag will skip extra marge commit")

git fetch ("Fetching downloads a branch from another repository, along with all of its associated commits and files")

git merge branch_name ("Merge with current and othe branch")

git fetch --all ("Fetch all branch and commits")

git branch ("To show all branch")

git checkout branch_name ("To switch a branch")

git branch -d branch_name ("To delete a branch")

git clean ("Removes untracked files from the Working directory")

git clone ("Creates a copy of an existing repository")

git checkout -b branch_name ("Creating a new branch and switch to that branch")

git reset --hard Head~ ("Remove the last commit parmanently")

git reset --soft Head~ ("Undo the last commit")

git log --oneline ("To see the short version of commit message list")

git log --pretty=oneline ("It will show the commit message oneline with long hash character")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment