I have some code in my local directory I don't want to loose. Another dev worked on the code on a remote repo. How can I track my code as old version of the code, and see the difference between my old code and his new code.
I did
git fetch
worked fine. and now git pull gives :
$ git pull
fatal: refusing to merge unrelated histories
$ git branch
* master
Then I did $ git pull --allow-unrelated-histories which probably I shouldn't have done, and now I get this log :
* commit f714790 (HEAD -> master)
|\ Merge: b5b3189 f96113e
| | Author: Louisro <[email protected]>
| | Date: Tue Nov 16 11:10:49 2021 0100
| |
| | Merge branch 'master' of https://bitbucket.org/boardlinedevs/boardline-2.1
| |
| * commit f96113e (origin/master)
| | Author: remote dev
| | Date: Mon Nov 15 20:15:35 2021 0530
| |
| | Minor
| |
| * commit 2d653d1
| | Author: remote dev
| | Date: Mon Nov 15 20:04:14 2021 0530
| |
| | Frequency Center
| |
| * commit cfd480f
| | Author: remote dev
| | Date: Mon Nov 15 19:58:40 2021 0530
| |
| | Profile Pages
| |
| * commit e8163ac
| | Author: remote dev
| | Date: Mon Nov 15 19:44:31 2021 0530
| |
| | Sorting and order
| |
| * commit 8725340
| | Author: remote dev
| | Date: Mon Nov 15 18:43:07 2021 0530
| |
| | Revet
| |
| * commit 085e4b9
| | Author: remote dev
| | Date: Mon Nov 15 18:42:42 2021 0530
| |
| | Winning Boards Fixes
| |
| * commit d0d6d3a
| | Author: remote dev
| | Date: Mon Nov 15 16:47:13 2021 0530
| |
| | UI Chnanges 1
| |
| * commit 2b0599c
| | Author: remote dev
| | Date: Mon Nov 15 14:21:08 2021 0530
| |
| | Upgrade
| |
| * commit c30cac4
| | Author: remote dev
| | Date: Fri Oct 22 13:07:21 2021 0530
| |
| | version 2.1 Patches
| |
| * commit 8484645
| | Author: remote dev
| | Date: Tue Dec 22 10:20:12 2020 0530
| |
| | v2.0
| |
| * commit 7d53386
| Author: louisrom1 <[email protected]>
| Date: Mon Dec 21 20:47:48 2020 0000
|
| Initial commit
|
* commit b5b3189 (tag: v1.651)
| Author: Louisro <[email protected]>
| Date: Sun Jul 13 15:50:04 2014 0200
|
| signin-page on iOS
|
* commit 5259900
| Author: Louisro <[email protected]>
| Date: Wed Mar 5 13:56:50 2014 0100
|
| avant google api
|
* commit aff9516
| Author: Louisro <[email protected]>
| Date: Wed Sep 25 12:21:23 2013 0200
|
| modif texte explanation Tom
|
* commit d399a63
| Author: Louisro <[email protected]>
| Date: Mon Jun 10 10:05:42 2013 0200
|
| contact panel with mailto
|
* commit b980cfa
| Author: Louisro <[email protected]>
| Date: Tue Jun 4 15:05:04 2013 0200
|
| big bottom button
|
* commit f0265d4
| Author: Louisro <[email protected]>
| Date: Tue Jun 4 14:58:11 2013 0200
|
| lots of shit
|
* commit 2aa8b13
| Author: Louisro <[email protected]>
| Date: Tue Jun 4 14:57:53 2013 0200
|
| lots of sit
|
* commit 7bc60eb
| Author: Louisro <[email protected]>
| Date: Thu May 23 13:32:00 2013 0200
|
| splash and explanation slideshow
|
* commit 62fca4d
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Thu Apr 18 10:43:12 2013 0200
|
| version avec jsShare
|
* commit e329cfe
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Thu Apr 18 00:21:15 2013 0200
|
| disable enable select is ok
|
* commit 1d41085
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Wed Apr 17 09:54:32 2013 0200
|
| version 3 boutons
|
* commit a49d512
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Mon Apr 15 17:27:53 2013 0200
|
| avant 3 boutons
|
* commit fd2c62b
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Tue Apr 9 22:19:27 2013 0200
|
| auto id ok
|
* commit 68e111b
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Tue Apr 9 22:04:04 2013 0200
|
| before auto id
|
* commit 4c4b133
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Sun Apr 7 21:45:40 2013 0200
|
| updated db
|
* commit 3bdcbbe
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Sun Apr 7 00:08:08 2013 0200
|
| file read
|
* commit 02f8a26
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Fri Apr 5 21:33:16 2013 0200
|
| compute diplay image ok
|
* commit 2e065b6
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Fri Apr 5 09:41:37 2013 0200
|
| file read
|
* commit 567136c (tag: 0.9.2beta)
| Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
| Date: Thu Apr 4 15:17:09 2013 0200
|
| single page
|
* commit 5926693 (tag: 0.9.1beta)
Author: louisro <louisro@louisro-ThinkPad-T400.(none)>
Date: Thu Apr 4 14:06:26 2013 0200
multi page
Whereas I would like all commits to be on the same line (same branch).
Can you help clean this mess ?
Thanks
EDIT Ok I managed to go back before the unfortunate git pull using $ git reset --hard HEAD~1
But now I still have to connect the local and remote branch, the idea is not to loose my local work and to be able to diff the changes made by the remote dev.
EDIT 2 now I have :
$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 20 and 11 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
Untracked files:
(use "git add <file>..." to include in what will be committed)
../.htaccess
../.htaccessbackup
../.htpasswd
../.~lock.accord de confidentialite.docx#
../13_02_2014_CDL_Introduction_Pitch.pdf
../BLPictoRapport.pdf
../BLtextonlyproof.txt
../BLtextonlyproofedbytTom.txt
../BOARDLINE presentation.pdf
../BoardLine.docx
../BoardLine.ipa
../Boardline input Sylvain.wav
../ESI_STOCK BOARD CATALOGUE 2013.xls
../FRANCE Shapers Tour.pdf
../Feedback_Ionic.pptx
../FlexSlider-7ecc526/
../GoogleService-Info.plist
../JQM_version/
../Ja.txt
../OpenFB-master/
../PR_BoardLine_NewBrands_Jan2015.doc
../Plan.xlsx
../Screens for developper ANUJ/
../ScreenshotBureauPhilippe.doc
../ScreenshotOrdiLouisRo.png
../Strategie.xlsx
CodePudding user response:
ok it seems that
$ git stash; git fetch origin; git reset --hard origin/master
did the job
CodePudding user response:
To get what you have asked for, you need to:
- reset away the merge (which you already did), then
- rebase or cherry-pick your original commits atop his commits, so that you add your commits to the history that consists of his commits.
You may (or may not) have some merge conflicts to deal with in step 2.
To do this with rebase, consider a simple:
git rebase origin/master
(though now that you have reset your own commits away, you will have to reset to put them back, using the reflogs or the raw hash IDs from your question, e.g., git reset --hard b5b3189
).