Git scenario cheat sheet

Merge

git merge new_feature
  1. Let's say, we want to copy all the code from new_feature branch into dev branch.

    In such a situation, first, we have to checkout in dev branch then we can execute the above command.

    The above command means bringing all the changes from new_feature branch into the current branch.

    Note: always pull before any merge i.e. after git checkout test do a pull request git pull after that do git merge new_feature

Remote branch

You have a lot of branch in you remote but when you did git clone <repo-url> and git branch. You can only able to see main branch. Now you want to see all the branch in your local machine.

for branch in `git branch -r | grep -v '\->'`; do
    git branch --track ${branch#origin/} $branch
done

git fetch --all