Skip to content

Instantly share code, notes, and snippets.

@delwar2016
Last active June 17, 2021 12:25
Show Gist options
  • Save delwar2016/c0be7b1ed305525f43fe87fa54ab9c53 to your computer and use it in GitHub Desktop.
Save delwar2016/c0be7b1ed305525f43fe87fa54ab9c53 to your computer and use it in GitHub Desktop.
Git common command ...
  1. For creating new branch

git checkout -b [new-branch-name]

Example: we want to create new branch named: new-branch-1

git checkout -b new-branch-1

  1. For swicthing existing branch

git checkout [branch-name]

  1. For push any changes to remote branch, there are three steps:

git add [changes/added file path]

git commit -m [message- reason for changes]

git push

for first time , i mean new branch. We need to run the following comman instand of git push

git push --set-upstream origin [new-branch-name]

When we need to update remote branch to local branch, then need to run following command-

git pull --rebase

  1. For clearing all changes and back to previous commit

git stash

  1. For merging

git merge [branch-name]

  1. For remove current merge

git stash (if we made any chages)

git reser HEAD^

remove manually all files which unstash

pick remote updated branch git pull --rebase

Please reset your local [branch-name] branch with origin git reset --hard origin/[branch-name]

@ivandrofly
Copy link

typo: oops...
correct: git reset HEAD^

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