-1

When i try to git pull origin develop... the problem is I know it's not up-to-date. I want to pull everything to get back to where everything is up-to-date with others commits.

If i have nothing else of importance in my local repository can i just re-pull from origin develop? I'm thinking it will overwrite everything but at least than i'll be up-to-date and have the save version is everyone else!?!?!?

This was my original workflow with git but somehow everything got skewed:

git add files_that_were_updated
git commit -m "Message."
git push origin BUG-#
git checkout develop
git fetch origin
git pull origin develop
git merge BUG-#
git push origin develop

Seems pretty standard and straightforward, no?

thismethod
  • 523
  • 1
  • 6
  • 25
  • Not really. What is the sense of pushing `BUG-#` just to merge it in right away? And if you `fetch`ed already, there is no reason to `pull`, but a simple `merge` is enough, as `pull` is `fetch`+`merge` or `fetch`+`rebase`, depending on your configuration and options. And btw. if you set up `origin/develop` as tracking branch for your local `develop` (probably is like that already) you don't need to tell where to push to or where to pull from. – Vampire May 24 '16 at 00:49
  • What is the failed output? Agreed, this sounds like it'll work. You've got a few too many commands in there, but nothing that'll do harm. – robrich May 24 '16 at 00:51

1 Answers1

0

It's not possible to see which branch you were, when you executed the first commit, so it is possible that you made the commit directly to the develop branch, thinking that you were on the BUG-# branch. That would explain why you get the "Already up-to-date" message, given that your local develop is now ahead of the develop on the remote repository.


An easy way to be sure you get the latest branch from the remote repository (e.g. origin), down to your repository, is to do a git fetch branchName:branchName --force, whilst you are in a different branch than branchName.

In your example, something like this:

# assuming you are on branch `BUG-#`
git add files_that_were_updated
git commit -m "Message."
git push origin BUG-#
git fetch origin develop:develop --force
...

The last command above will replace your local develop branch with the develop branch that is on the server where your origin remote is pointing to.

Notice that, to be able to do that, you cannot be in the same branch that is being replaced, so always go to a different branch first.

C. Augusto Proiete
  • 24,684
  • 2
  • 63
  • 91