How to "Pull" from a Local Branch into Another One?
This Sounds So Simple, but I Just Can't Figure It Out. I Made an Experimental Branch a While Ago, and Now I'd Like to Pull in All the Changes That Happened on...
This sounds so simple, but I just can't figure it out. I made an experimental branch a while ago, and now I'd like to pull in all the changes that happened on master since I made it. This is all local. I want to pull from local master into local my_branch, but I can't do it. This doesn't seem to work, telling me that master isn't a git repository:
git pull master
5 Answers
you have to tell git where to pull from, in this case from the current directory/repository:
git pull . master
but when working locally, you usually just call merge (pull internally calls merge):
git merge master
What you are looking for is merging.
git merge master
With pull you fetch changes from a remote repository and merge them into the current branch.
Quite old post, but it might help somebody new into git.
I will go with
git rebase master
- much cleaner log history and no merge commits (if done properly)
- need to deal with conflicts, but it's not that difficult.
If you want to do the step 3 shown in the picture. Then follow the step below.
- git switch b (make sure you are in the same branch where you want to merge)
- git merge b ( this command indicating that you are merging b into a)
If you are looking for a brand new pull from another branch like from local to master you can follow this.
git commit -m "Initial Commit"
git add .
git pull --rebase git_url
git push origin master