Skip to content

Instantly share code, notes, and snippets.

@ShivG9
Forked from delwar2016/git-common-command.md
Created June 17, 2021 12:25
Show Gist options
  • Save ShivG9/e4f515c3ca59517ad4060cf61d1fae36 to your computer and use it in GitHub Desktop.
Save ShivG9/e4f515c3ca59517ad4060cf61d1fae36 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]

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