×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

Reset git fork to head

  • Posts: 77
  • Thank you received: 14
I am getting very annoyed, mainly due to my lack of experience with git.

I have developed a driver for a focuser in indi, but I am fighting git at every turn. I had an hour, and wanted to add a feature, but have just spent the last hour trying to sync my development with the head end, and every time I am told I have a conflict I have t merge. I don't care about the conflict, just replace my fork with the latest master, that should not be difficult! for the life of me I cannot seem to give the correct commands...
here is the end of my command window showing what I am doing, I have tried lots of combinations, but always end up with the same conflict. I just want my fork to be replaced with what ever is in the master, and overwrite any conflicts.

Please could someone please tell me what command sequence I need?

alan@alan-kubuntu:~/indi$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
alan@alan-kubuntu:~/indi$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
alan@alan-kubuntu:~/indi$ git pull
remote: Enumerating objects: 49, done.
remote: Counting objects: 100% (49/49), done.
remote: Total 63 (delta 49), reused 49 (delta 49), pack-reused 14
Unpacking objects: 100% (63/63), done.
From github.com/ajt68/indi
3ae1993..4e34df7 master -> origin/master
Updating 3ae1993..4e34df7
Fast-forward
CMakeLists.txt | 19 +-
debian/changelog | 6 +
drivers.xml | 6 +-
drivers/focuser/deepskydad_af3.cpp | 907 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
drivers/focuser/deepskydad_af3.h | 147 +++++++++++++
drivers/focuser/focuslynxbase.cpp | 22 +-
drivers/focuser/myfocuserpro2.cpp | 3 +-
indiapi.h | 2 +-
indidriver.c | 58 +++++
indidriver.h | 14 +-
libs/indibase/indidome.cpp | 38 +++-
11 files changed, 1197 insertions(+), 25 deletions(-)
create mode 100755 drivers/focuser/deepskydad_af3.cpp
create mode 100755 drivers/focuser/deepskydad_af3.h
alan@alan-kubuntu:~/indi$ git pull
Already up-to-date.
alan@alan-kubuntu:~/indi$ git remote -v
origin ht..//github.com/ajt68/indi.git (fetch)
origin ht..//github.com/ajt68/indi.git (push)
upstream ht..//github.com/indilib/indi.git (fetch)
upstream ht..//github.com/indilib/indi.git (push)
alan@alan-kubuntu:~/indi$ git fetch upstream
remote: Enumerating objects: 74, done.
remote: Counting objects: 100% (74/74), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 75 (delta 66), reused 72 (delta 66), pack-reused 1
Unpacking objects: 100% (75/75), done.
From github.com/indilib/indi
5605ecb..1b6cdde master -> upstream/master
alan@alan-kubuntu:~/indi$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
alan@alan-kubuntu:~/indi$ git merge upstream/master
Auto-merging drivers/focuser/myfocuserpro2.h
Auto-merging drivers/focuser/myfocuserpro2.cpp
CONFLICT (content): Merge conflict in drivers/focuser/myfocuserpro2.cpp
Automatic merge failed; fix conflicts and then commit the result.
alan@alan-kubuntu:~/indi$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
You have unmerged paths.
(fix conflicts and run "git commit")

Changes to be committed:

modified: drivers.xml
modified: drivers/auxiliary/arduino_st4.cpp
modified: drivers/auxiliary/usb_dewpoint.cpp
modified: drivers/dome/baader_dome.cpp
modified: drivers/dome/dome_script.cpp
modified: drivers/dome/roll_off.cpp
modified: drivers/filter_wheel/xagyl_wheel.cpp
modified: drivers/focuser/aaf2.cpp
modified: drivers/focuser/celestron.cpp
modified: drivers/focuser/deepskydad_af1.cpp
modified: drivers/focuser/deepskydad_af2.cpp
modified: drivers/focuser/deepskydad_af3.cpp
modified: drivers/focuser/dmfc.cpp
modified: drivers/focuser/focuslynx.cpp
modified: drivers/focuser/focuslynxbase.cpp
modified: drivers/focuser/lakeside.cpp
modified: drivers/focuser/lakeside.h
modified: drivers/focuser/microtouch.cpp
modified: drivers/focuser/moonlite.cpp
modified: drivers/focuser/moonlite_dro.cpp
modified: drivers/focuser/myfocuserpro2.h
modified: drivers/focuser/nstep.cpp
modified: drivers/focuser/onfocus.cpp
modified: drivers/focuser/robofocus.cpp
modified: drivers/focuser/sestosenso.cpp
modified: drivers/focuser/steeldrive.cpp
modified: drivers/focuser/usbfocusv3.cpp
modified: drivers/rotator/gemini.cpp
modified: drivers/rotator/nightcrawler.cpp
modified: drivers/rotator/pyxis.cpp
modified: drivers/skeleton/mount_driver.cpp
modified: drivers/telescope/celestrongps.cpp
modified: drivers/telescope/dsc.cpp
modified: drivers/telescope/dsc.h
modified: drivers/telescope/lx200_OnStep.cpp
modified: drivers/telescope/pmc8driver.cpp
modified: drivers/telescope/telescope_script.cpp
modified: drivers/telescope/temmadriver.cpp
modified: drivers/video/v4l2driver.cpp
modified: drivers/weather/mbox.cpp
modified: indidriver.h
modified: libs/indibase/connectionplugins/connectionserial.cpp
modified: libs/indibase/indidome.cpp
modified: libs/indibase/indifocuserinterface.h
modified: libs/indibase/indiweather.h

Unmerged paths:
(use "git add <file>..." to mark resolution)

both modified: drivers/focuser/myfocuserpro2.cpp

alan@alan-kubuntu:~/indi$ rm drivers/focuser/myfocuserpro2.cpp
alan@alan-kubuntu:~/indi$ git merge upstream/master
error: merge is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
alan@alan-kubuntu:~/indi$ git checkout master
drivers/focuser/myfocuserpro2.cpp: needs merge
error: you need to resolve your current index first
alan@alan-kubuntu:~/indi$ git merge upstream/master
error: merge is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
alan@alan-kubuntu:~/indi$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
You have unmerged paths.
(fix conflicts and run "git commit")

Changes to be committed:

modified: drivers.xml
modified: drivers/auxiliary/arduino_st4.cpp
modified: drivers/auxiliary/usb_dewpoint.cpp
modified: drivers/dome/baader_dome.cpp
modified: drivers/dome/dome_script.cpp
modified: drivers/dome/roll_off.cpp
modified: drivers/filter_wheel/xagyl_wheel.cpp
modified: drivers/focuser/aaf2.cpp
modified: drivers/focuser/celestron.cpp
modified: drivers/focuser/deepskydad_af1.cpp
modified: drivers/focuser/deepskydad_af2.cpp
modified: drivers/focuser/deepskydad_af3.cpp
modified: drivers/focuser/dmfc.cpp
modified: drivers/focuser/focuslynx.cpp
modified: drivers/focuser/focuslynxbase.cpp
modified: drivers/focuser/lakeside.cpp
modified: drivers/focuser/lakeside.h
modified: drivers/focuser/microtouch.cpp
modified: drivers/focuser/moonlite.cpp
modified: drivers/focuser/moonlite_dro.cpp
modified: drivers/focuser/myfocuserpro2.h
modified: drivers/focuser/nstep.cpp
modified: drivers/focuser/onfocus.cpp
modified: drivers/focuser/robofocus.cpp
modified: drivers/focuser/sestosenso.cpp
modified: drivers/focuser/steeldrive.cpp
modified: drivers/focuser/usbfocusv3.cpp
modified: drivers/rotator/gemini.cpp
modified: drivers/rotator/nightcrawler.cpp
modified: drivers/rotator/pyxis.cpp
modified: drivers/skeleton/mount_driver.cpp
modified: drivers/telescope/celestrongps.cpp
modified: drivers/telescope/dsc.cpp
modified: drivers/telescope/dsc.h
modified: drivers/telescope/lx200_OnStep.cpp
modified: drivers/telescope/pmc8driver.cpp
modified: drivers/telescope/telescope_script.cpp
modified: drivers/telescope/temmadriver.cpp
modified: drivers/video/v4l2driver.cpp
modified: drivers/weather/mbox.cpp
modified: indidriver.h
modified: libs/indibase/connectionplugins/connectionserial.cpp
modified: libs/indibase/indidome.cpp
modified: libs/indibase/indifocuserinterface.h
modified: libs/indibase/indiweather.h

Unmerged paths:
(use "git add <file>..." to mark resolution)

both modified: drivers/focuser/myfocuserpro2.cpp

alan@alan-kubuntu:~/indi$ git fetch -all
error: did you mean `--all` (with two dashes ?)
alan@alan-kubuntu:~/indi$ git fetch --all
Fetching origin
Fetching upstream
alan@alan-kubuntu:~/indi$ git reset --hard origin/master
HEAD is now at 4e34df7 Merge branch 'master' into master
alan@alan-kubuntu:~/indi$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
alan@alan-kubuntu:~/indi$ git merge upstream/master
Auto-merging drivers/focuser/myfocuserpro2.h
Auto-merging drivers/focuser/myfocuserpro2.cpp
CONFLICT (content): Merge conflict in drivers/focuser/myfocuserpro2.cpp
Automatic merge failed; fix conflicts and then commit the result.
alan@alan-kubuntu:~/indi$ git reset --hard origin/master
HEAD is now at 4e34df7 Merge branch 'master' into master
alan@alan-kubuntu:~/indi$ git merge upstream/master
Auto-merging drivers/focuser/myfocuserpro2.h
Auto-merging drivers/focuser/myfocuserpro2.cpp
CONFLICT (content): Merge conflict in drivers/focuser/myfocuserpro2.cpp
Automatic merge failed; fix conflicts and then commit the result.
alan@alan-kubuntu:~/indi$ git reset --hard origin/master
HEAD is now at 4e34df7 Merge branch 'master' into master
alan@alan-kubuntu:~/indi$ rm drivers/focuser/myfocuserpro2.cpp
alan@alan-kubuntu:~/indi$ ls drivers/focuser/my*
drivers/focuser/myfocuserpro2.h
alan@alan-kubuntu:~/indi$ git merge upstream/master
Auto-merging drivers/focuser/myfocuserpro2.h
Auto-merging drivers/focuser/myfocuserpro2.cpp
CONFLICT (content): Merge conflict in drivers/focuser/myfocuserpro2.cpp
Automatic merge failed; fix conflicts and then commit the result.
alan@alan-kubuntu:~/indi$ nano drivers/focuser/myfocuserpro2.cpp
alan@alan-kubuntu:~/indi$ git reset --hard HEAD
HEAD is now at 4e34df7 Merge branch 'master' into master
alan@alan-kubuntu:~/indi$ git pull
Already up-to-date.
alan@alan-kubuntu:~/indi$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
alan@alan-kubuntu:~/indi$ git fetch --all
Fetching origin
Fetching upstream
alan@alan-kubuntu:~/indi$ git reset --hard origin/master
HEAD is now at 4e34df7 Merge branch 'master' into master
alan@alan-kubuntu:~/indi$ git merge upstream/master
Auto-merging drivers/focuser/myfocuserpro2.h
Auto-merging drivers/focuser/myfocuserpro2.cpp
CONFLICT (content): Merge conflict in drivers/focuser/myfocuserpro2.cpp
Automatic merge failed; fix conflicts and then commit the result.
alan@alan-kubuntu:~/indi$ git reset --hard origin/master
HEAD is now at 4e34df7 Merge branch 'master' into master
alan@alan-kubuntu:~/indi$ git fetch upstream
alan@alan-kubuntu:~/indi$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
alan@alan-kubuntu:~/indi$ git fetch upstream
alan@alan-kubuntu:~/indi$ git reset --hard origin/master
HEAD is now at 4e34df7 Merge branch 'master' into master
alan@alan-kubuntu:~/indi$ git merge upstream/master
Auto-merging drivers/focuser/myfocuserpro2.h
Auto-merging drivers/focuser/myfocuserpro2.cpp
CONFLICT (content): Merge conflict in drivers/focuser/myfocuserpro2.cpp
Automatic merge failed; fix conflicts and then commit the result.
alan@alan-kubuntu:~/indi$ git pull
error: Pull is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
alan@alan-kubuntu:~/indi$ git fetch upstream
alan@alan-kubuntu:~/indi$ git checkout master
drivers/focuser/myfocuserpro2.cpp: needs merge
error: you need to resolve your current index first
alan@alan-kubuntu:~/indi$ git reset --hard origin/master
HEAD is now at 4e34df7 Merge branch 'master' into master
alan@alan-kubuntu:~/indi$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
alan@alan-kubuntu:~/indi$ git merge -s recursive -X theirs origin/master
Already up-to-date.
alan@alan-kubuntu:~/indi$ git fetch upstream
alan@alan-kubuntu:~/indi$ git merge -s recursive -X theirs origin/master
Already up-to-date.
alan@alan-kubuntu:~/indi$ git merge upstream/master
Auto-merging drivers/focuser/myfocuserpro2.h
Auto-merging drivers/focuser/myfocuserpro2.cpp
CONFLICT (content): Merge conflict in drivers/focuser/myfocuserpro2.cpp
Automatic merge failed; fix conflicts and then commit the result.
alan@alan-kubuntu:~/indi$ git merge -s recursive -X theirs origin/master
error: merge is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
alan@alan-kubuntu:~/indi$ git reset --hard origin/master
HEAD is now at 4e34df7 Merge branch 'master' into master
alan@alan-kubuntu:~/indi$ git merge -s recursive -X theirs origin/master
Already up-to-date.
alan@alan-kubuntu:~/indi$ git clean
fatal: clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean
alan@alan-kubuntu:~/indi$ git fetch origin master
From github.com/ajt68/indi
* branch master -> FETCH_HEAD
alan@alan-kubuntu:~/indi$ git reset --hard origin/master
HEAD is now at 4e34df7 Merge branch 'master' into master
4 years 6 months ago #44926

Please Log in or Create an account to join the conversation.

  • Posts: 1187
  • Thank you received: 370
Hi Alan,
it is not so clear what your intention is. Let me try to explain, what I understood.

I guess you developed your version of myfocuserpro2.cpp and committed this on your fork. Now the upstream repository has a newer version. Do you want to get rid of your implementation and switch back to upstream?

Or do you want to keep your changes but merge the changes from upstream?

- Wolfgang
4 years 6 months ago #44933

Please Log in or Create an account to join the conversation.

  • Posts: 77
  • Thank you received: 14
Hi and hanks for the reply.

You are partially correct, my changes have already been committed to the upstream, but other people have since committed too, and I obviously don't have there changes. I just want my fork to reflect what is on the upstream (main branch?).

Everything I do insists that a file needs to be maually merged, which technically is true, but I don't care what the file contains, just throw my version away and replce with the upstream.
In terms that I understand I would say "Delete the contents of my fork, then copy the upstream back into my fork" or "Replace my fork contents with the upstream version"

At this precise moment I seem to have a commit, which I don't want or maybe I do (I just don't know!!), and was generated whilst trying to achieve what I am currently asking. I just seem to be getting in a right mess trying to do something that on the surface seems like it should be pretty simple!

Should I just delete my fork and create a new one, but I then think I will loose my build environment changes in qtcreator?

All I want to do is replace my fork with the upstream :(
4 years 6 months ago #44943

Please Log in or Create an account to join the conversation.

  • Posts: 1187
  • Thank you received: 370
Ok, understood. So the steps are the following:
  1. Delete your own changes from your local repository
  2. Rebase your local master branch to upstream/master
  3. Force a push from your local repository to the original
But please be aware that your changes get lost!

Here are the commands, assuming your current working directory is the kstars directory.
git reset HEAD~10 —hard
git rebase upstream/master
git push —force-with-lease

The first command assumes that you made at most 10 own commits. If you did more, increase the number after „~“. It doesn’t matter if you delete more than necessary. Rebasing will heal this.

HTH
Wolfgang
The following user(s) said Thank You: Alan Townshend
4 years 6 months ago #44950

Please Log in or Create an account to join the conversation.

  • Posts: 77
  • Thank you received: 14
Thanks!!!! That is exactly what I was after. I am now ready to start coding again.

Unfortunately/fortunately it's clear here tonight, so coding will have to wait (Only had two clear nights in three weeks :( )
4 years 6 months ago #44952

Please Log in or Create an account to join the conversation.

  • Posts: 1187
  • Thank you received: 370
In general I would recommend developing your own changes on a branch. I keep the master in my fork clean an do all my development on a separate branch. As soon as they are mature enough, I create a push request so that they hopefully land somewhen in the master.

Typically, the sequence is the following:
  • git checkout -b my_branch_name
  • ... code ...
  • git commit -a
  • git push
  • git checkout master
  • git rebase upstream/master
  • git checkout my_branch_name
  • git rebase master
  • ... code ...
4 years 6 months ago #44956

Please Log in or Create an account to join the conversation.

Time to create page: 0.526 seconds