Reputation: 91
So, I have just merged a feature branch to master and currently master has the latest code.
Now, I want to create a new feature branch and want to start working on it with the code that is currently in master. What should I do? Where do I checkout and pull?
Does git pull
do it?
Upvotes: 0
Views: 725
Reputation: 66
Assuming, you want online master branch changes irrespective of what you have on local master. Execute the following commands in order:
1 - git checkout master
2 - git fetch origin master
3 - git reset --hard origin/master
4 - git checkout -b <your_branch_name>
This will take care in case you get any local merge conflict while using "git pull origin master"
Upvotes: 2
Reputation: 462
When you checkout master, you're switching to that codebase. When you pull from origin, you're updating your local copy to whatever is on the codebase. When you checkout a new branch, you start from the previous branches codebase.
git checkout master
git pull origin master
git checkout -b <new branch>
That should work.
To see what will be merged before actually merging you can use this instead of pull
git fetch origin master
Upvotes: 0