4

I have a project on Github, but I'm struggling to get the changes from it to my local machine. I recently deployed an app using Fortrabbit, which involved creating a new remote repo to push all the files to – now (I'm a noob) I'm struggling to return to pulling and pushing changes to the origin.

If I run git status

On branch master
Your branch is up-to-date with 'fortrabbit/master'.

nothing to commit, working directory clean

If I run git fetch origin I get no errors, just back to the command line.

If I run git status again I still get

On branch master
Your branch is up-to-date with 'fortrabbit/master'.

nothing to commit, working directory clean

I want this to say Your branch is up-to-date with 'origin/master'.

git remote -v Gives me the two repos (I think?)

fortrabbit  git@git8.eu1.frbit.com:app.git (fetch)
fortrabbit  git@git8.eu1.frbit.com:app.git (push)
origin  https://github.com/djave/app.git (fetch)
origin  https://github.com/djave/app.git (push)

I just need to git change repo origin or something? How do I tell git that I want to go back to syncing with origin?

Sascha Wolf
  • 18,810
  • 4
  • 51
  • 73
Djave
  • 8,595
  • 8
  • 70
  • 124
  • Kind of related question: https://stackoverflow.com/questions/4878249/how-to-change-the-remote-a-branch-is-tracking/4879224 The top upvoted answer also solves this question – Kenrick Aug 16 '22 at 06:38

1 Answers1

5

You should be able to fix this using git branch --set-upstream master origin/master which basically says that your current local branch should correspond to the master branch on origin.

Serban Constantin
  • 3,316
  • 1
  • 18
  • 20
  • I adore you. Easy when you know how. One final point, I get the following: `The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to Branch master set up to track remote branch master from origin.` – in future would I just use `git branch --set-upstream-to master origin/master`? – Djave Feb 10 '15 at 12:14
  • 1
    Well, you can just use `git push -u remote branch` so that from that point on that branch will be tracked to the branch on the remote you pushed to (just replace remote and branch with the remote and branch name you want). After that first push you can just use git push and it'll automatically push to the remote on that particular branch. See [git-push documentation](http://git-scm.com/docs/git-push) for more info. – Serban Constantin Feb 10 '15 at 12:17
  • 2
    Also, yes, in the future you can just use `git branch --set-upstream-to master origin/master` instead of `--set-upstream`. Note that you only have to do this once per branch (or alternatively use `git push -u` when first pushing that branch to the remote). – Serban Constantin Feb 10 '15 at 12:19