- 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
- For swicthing existing branch
git checkout [branch-name]
- 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
- For clearing all changes and back to previous commit
git stash
- For merging
git merge [branch-name]
- 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]
typo: oops...
correct: git reset HEAD^