Board index FlightGear Development

GIT help - resetting

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 help - resetting

Postby jam007 » Sun Apr 28, 2013 7:34 pm

I have constant trouble with GIT.
After being asked to "rebase" my commitments and my efforts to do so nothing really works as I want.
Now I would like to start all over again.
I followed the instructions in the wiki to make my clone and my local copy.
How do I do to start a fresh again. Remove the branches and my local data?
jam007
 
Posts: 579
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: GIT help - resetting

Postby AndersG » Sun Apr 28, 2013 7:48 pm

Don't remove anything! If you have a local clone of fgdata you have everything at hand - starting over is just creating a new local branch that tracks master, e.g.:

git branch my-new-master origin/master
git checkout my-new-master

And update it to latest with (I recommend using --rebase in the future since that will keep your local commits after all up stream commits):
git pull --rebase

Use
git status
and
git diff
to investigate what ever uncommitted changes you may have in your tree.
If you want to throw all such changes away, use
git reset --hard

Or you can use
git stash
to save them for later.

If you have an old branch with your work and want to reapply selected commits to the new one, git cherry-pick is a useful command.

/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: 2524
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: GIT help - resetting

Postby jam007 » Mon Apr 29, 2013 1:16 pm

What is best to do with my clone on gitorious?
I would like to have that as a new clone from the current FG data and then add my changes as one commit.
jam007
 
Posts: 579
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: GIT help - resetting

Postby AndersG » Mon Apr 29, 2013 4:56 pm

jam007 wrote in Mon Apr 29, 2013 1:16 pm:What is best to do with my clone on gitorious?
I would like to have that as a new clone from the current FG data and then add my changes as one commit.


Deleting it and creating it again is easiest for you and best for gitorious.

[EDIT]
Once done you can update the gitorious remote entry in your local git clone of fgdata to make it convenient to push to your clone at gitorious (if the name changes in the recreation at gitorious). See the git remote -h .
[/EDIT]

/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: 2524
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: GIT help - resetting

Postby jam007 » Tue Apr 30, 2013 11:05 am

I deleted the remote and made anew branch master2. Then I reset that and the files reverted to the status in GIT. Then I copied my saved aircraft files to the directory. Used git add -A and commit etc. following the wiki. Still when I want to push them to my clone I errors about "non-fast-forward updates". :( :x

Code: Select all
andersm@Surprise:~/GIT/fgdata$ git rebase origin/master
Current branch master2 is up to date.
andersm@Surprise:~/GIT/fgdata$ git push git@gitorious.org:~andersm/fg/andersms-fgdata.git
To git@gitorious.org:~andersm/fg/andersms-fgdata.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@gitorious.org:~andersm/fg/andersms-fgdata.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
andersm@Surprise:~/GIT/fgdata$ git pull --rebase
Current branch master2 is up to date.
andersm@Surprise:~/GIT/fgdata$ git push git@gitorious.org:~andersm/fg/andersms-fgdata.git
To git@gitorious.org:~andersm/fg/andersms-fgdata.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@gitorious.org:~andersm/fg/andersms-fgdata.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
jam007
 
Posts: 579
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: GIT help - resetting

Postby AndersG » Tue Apr 30, 2013 1:45 pm

Hmm.. does the master branch at your gitorious repository contain newer upstream commits than your local branch?
If so you can use git pull --rebase to update your local branch.

And, in any case you can also force your will through:
Code: Select all
git push -f git@gitorious.org:~andersm/fg/andersms-fgdata.git master

However, you might need to change a setting on your gitorious clone to be able to do that - there is a safe-guard setting to disallow non-fast-forward updates. Non-fast-forward updates are unfriendly to people tracking a branch in a public repository - but that is usually not an issue for a personal clone.

/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: 2524
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: GIT help - resetting

Postby jam007 » Tue Apr 30, 2013 2:28 pm

pull --rebase did not make a difference.

After forcing push some old changes appeared on git: https://gitorious.org/~andersm/fg/andersms-fgdata :?
But not the one I made today...

Isn't there a way to start all over again?
And then make a single commit with all updates the last months. So that I can make a merge request on that.
jam007
 
Posts: 579
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: GIT help - resetting

Postby AndersG » Tue Apr 30, 2013 3:22 pm

You pushed the branch master, right? It looks like that at gitorious, at least. Are you sure that is your current branch?
Check with
Code: Select all
git branch


When you push you can also rename the branch by entering local-name:new-remote-name instead of just the branch name. E.g.
Code: Select all
git push gitorius my-local-master:master


IIRC you can also delete a remote branch by pushing nothing to it:
Code: Select all
git push gitorious :remote-branch-to-delete


/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: 2524
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: GIT help - resetting

Postby jam007 » Tue Apr 30, 2013 3:36 pm

:?:
I thought I was on my new branch master2 that I created
According to git branch I am..
Why does it push from another branch?
How do I "unpush"?
jam007
 
Posts: 579
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: GIT help - resetting

Postby jam007 » Tue Apr 30, 2013 5:09 pm

After deleting the old branches. Renaming master2 to master. Deleting the clone on gitorious and creating a new I finally managed to get one push with all new materials since the one already on GIT. Phew...

Do not look forward to next time...
jam007
 
Posts: 579
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: GIT help - resetting

Postby AndersG » Tue Apr 30, 2013 11:11 pm

I suppose you did not notice that branch names were part of my example commands?
So
Code: Select all
git push gitorious master2

or, if you want to call the branch master at gitorious,
Code: Select all
git push gitorious master2:master

would have done the trick.

/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: 2524
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: GIT help - resetting

Postby jam007 » Wed May 01, 2013 8:12 am

Tried: git push gitorious master2:master before deleting but got some error again. After deleting the local master and renaming master2 to master it finally worked.
Thanks for your efforts to help!
jam007
 
Posts: 579
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04


Return to Development

Who is online

Users browsing this forum: No registered users and 9 guests