Board index FlightGear Development

Git push from local branch to origin/master  Topic is solved

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Git push from local branch to origin/master

Postby Philosopher » Mon Sep 30, 2013 7:42 pm

I'm having trouble pushing to fg/fgdata on Gitorious. I have a local branch that contains an old master and a commit I would like to push (https://gitorious.org/fg/fgdata/merge_requests/115). These are the steps I followed:
Code: Select all
philosopher: ~/fgdata (master)$ git checkout topics/issue1185 # get the old branch
Checking out files: 100% (1131/1131), done.
Switched to branch 'topics/issue1185'

philosopher: ~/fgdata (topics/issue1185)$ git pull --rebase origin master # update it
remote: Counting objects: 24, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 15 (delta 12), reused 0 (delta 0)
Unpacking objects: 100% (15/15), done.
From gitorious.org:fg/fgdata
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: Fix for #1185

philosopher: ~/fgdata (topics/issue1185)$ git log # check work
# looks OK, have all recent commits and mine on top

philosopher: ~/fgdata (topics/issue1185)$ git push origin master # try pushing
To git@gitorious.org:fg/fgdata.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@gitorious.org:fg/fgdata.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and merge the remote changes
hint: (e.g. 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

philosopher: ~/fgdata (topics/issue1185)$ git branch -u origin/master # see if setting a upstream helps
Branch topics/issue1185 set up to track remote branch master from origin.

philosopher: ~/fgdata (topics/issue1185)$ git push origin master # try again...
# ... same output as above

philosopher: ~/fgdata (topics/issue1185)$ git remote show origin
* remote origin
  Fetch URL: git@gitorious.org:fg/fgdata.git
  Push  URL: git@gitorious.org:fg/fgdata.git
  HEAD branch: master
  Remote branches:
    master                tracked
    ...
  Local branch configured for 'git pull':
    topics/issue1185 merges with remote master
  Local ref configured for 'git push':
    master pushes to master (local out of date)


This looks like it's trying to push from the local master branch (which is outdated) instead of the current branch? (In the "git remote show origin" it looks like it is only set for pulling, after setting the upstream.) How do I push to Gitorious like this?
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Git push from local branch to origin/master  

Postby AndersG » Mon Sep 30, 2013 7:45 pm

With
Code: Select all
$ git push origin master

you are telling git you want to push your local master branch to origin.

Try
Code: Select all
$ git push origin topics/issue1185:master

instead. The pattern is <local name>:<remote name>.

It is good that you rebase instead of merge before pushing. Don't forget to have a last look with git diff origin/master to double check that everything looks ok before pushing. :)

/Anders
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2448
Joined: Wed Nov 29, 2006 9:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: Git push from local branch to origin/master

Postby Philosopher » Mon Sep 30, 2013 7:54 pm

Thank you! I wasn't aware of that syntax and I missed it in the documentation. It worked!

P.S. I've checked the diff many times ;). Honestly I don't know what I would do without diffs...
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Git push from local branch to origin/master

Postby zakalawe » Mon Sep 30, 2013 8:49 pm

A small suggestion, in general what you're doing looks good, especially the rebasing. (Also remember you can use interactive rebase to amend and squash commits before pushing).

Anyway, I would suggest merging to master locally, and then using your original push command. The end result is almost the same, but it gives you a chance to view the combined version before pushing. The end result is identical to what Anders has described above though, it's purely a what-works-for-you choice.
zakalawe
 
Posts: 1152
Joined: Sat Jul 19, 2008 4:48 pm
Location: Edinburgh, Scotland
Callsign: G-ZKLW
Version: next
OS: Mac


Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest