I use the sync subcommand of hub to automate this.
hub sync
This updates all local branches that have a matching upstream branch. From the man page:
- If the local branch is outdated, fast-forward it;
- If the local branch contains unpushed work, warn about it;
- If the branch seems merged and its upstream branch was deleted, delete it.
It also handles stashing/unstashing uncommitted changes on the current branch.
I used to use a similar tool called git-up, but it's no longer maintained, and git sync does almost exactly the same thing.
I use the sync subcommand of hub to automate this.
hub sync
This updates all local branches that have a matching upstream branch. From the man page:
- If the local branch is outdated, fast-forward it;
- If the local branch contains unpushed work, warn about it;
- If the branch seems merged and its upstream branch was deleted, delete it.
It also handles stashing/unstashing uncommitted changes on the current branch.
I used to use a similar tool called git-up, but it's no longer maintained, and git sync does almost exactly the same thing.
The behavior you describe for pull --all is exactly as expected, though not necessarily useful. The option is passed along to git fetch, which then fetches all refs from all remotes, instead of just the needed one; pull then merges (or in your case, rebases) the appropriate single branch.
If you want to check out other branches, you're going to have to check them out. And yes, merging (and rebasing) absolutely require a work tree, so they cannot be done without checking out the other branches. You could wrap up your described steps into a script/alias if you like, though I'd suggest joining the commands with && so that should one of them fail, it won't try to plow on.
So I have an issue when doing a pull from a remote branch. It doesn't update every single folder or directory but it also keep some files in my local repo without removing. Basically I want an entire copy of the remote branch because something within my local repo is breaking the program. Is there anyway to do this?
Check whether you are on the right branch and have checked out the same revision you are comparing to: git checkout HEAD
I had a similar problem, but needed a different solution. The local versions on one computer were not getting updated from the GitHub repo, which was ahead based on work I had done and pushed from a second computer the night before. It kept telling me all files were up-to-date, even though clearly the ones on the first computer were not the same as the ones on the second or the GitHub repo.
What finally fixed this problem for me was adding a trash .txt file on the second computer (new and different from everything else there, so there would be no merge conflicts). I pushed that file to the repo, then made a new attempt to pull from the first. When it saw the new file it made the pull, and took all the other changes as well.
I'm sure there was a better soltution, and this is something I was doing wrong with git, but since it worked I wanted to post it, in case anyone else is having the problem I was.