LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-09-2023, 01:15 AM   #1
MakeTopSite
Member
 
Registered: Jan 2021
Location: EU
Distribution: Ubuntu, openSUSE Leap & TW, Devuan, Debian
Posts: 290

Rep: Reputation: 3
git: Your branch and 'origin/master' have diverged, and have 1 and 3 different commits each, respectively.


... after I had removed last 3 commits and pushed to remote:
Code:
git reset HEAD^ --hard
git reset HEAD^ --hard
git reset HEAD^ --hard
git push https://gitlab.com/myname/myproj  -f
Code:
git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean
What will happen please if I run
Code:
git pull
?
 
Old 11-09-2023, 07:34 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,879
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
You can find out: just copy the whole directory-structure and try `git pull` on the copy.
 
Old 11-09-2023, 09:00 AM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
If you’re worried, you branch from your branch, and then do the pull.

(I assume you didn’t actually want an easily googlable explanation of how merges work?)

Last edited by dugan; 11-09-2023 at 09:18 AM.
 
Old 11-12-2023, 02:40 AM   #4
MakeTopSite
Member
 
Registered: Jan 2021
Location: EU
Distribution: Ubuntu, openSUSE Leap & TW, Devuan, Debian
Posts: 290

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by NevemTeve View Post
You can find out: just copy the whole directory-structure and try `git pull` on the copy.
Thank you, output of

Code:
git pull
was empty but it has solved the problem.
 
Old 11-12-2023, 02:49 AM   #5
MakeTopSite
Member
 
Registered: Jan 2021
Location: EU
Distribution: Ubuntu, openSUSE Leap & TW, Devuan, Debian
Posts: 290

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by dugan View Post
If you’re worried, you branch from your branch, and then do the pull.

(I assume you didn’t actually want an easily googlable explanation of how merges work?)
When I find some stuff about git command and use it, the result is sometime different than expected. And the difference is usualy undesirable and require another fix which requires another searching of the web. (This is why I had to remove last 3 commits and pushed to remote.) So I wanted to ask to be sure so as not to make things even worse.
 
Old 11-12-2023, 09:51 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,683
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
Git was telling you that it thought that the remote branch had commits that you didn't have, and that you had commits that the remote didn't have. It was instructing you to "pull" the remote commits down, so that what you then "pushed" would consider those commits and thus maintain the proper sequence.

– – –

It's very important to remember that Git considers everyone's system to be "a repository." The true genius of this system is that: "there is no 'one authoritative source of truth – there is no 'server.'"

Instead – and this will save your a&s!! – "everyone is 'a backup.'"

Naturally, there are certain specific "agreed-upon 'authoritative sources'" that are very carefully maintained – through "pull requests" and so-forth – but the central concept is still grounded in "mutual synchronization." Which happens to be an idea that had never been done before . . . ("Typical Linus ...") "Your repository is 'not in-sync' with theirs, because you have updates they don't have, and they have updates you don't have." Git provides a very straightforward way to deal with that.

But, for the individual developer working on his own machine, "effective version control." No 'server,' no mess, no bother. "Oh sh&t, I just screwed up ..." Solution: "Poof!" ... ... "Oh sh&t, I actually didn't screw up ..." Again: "Poof!"

I can very-confidently tell you that there is not a single "project directory," on any one of my (fairly recent ...) personal systems, which isn't 'a Git repository.' That's the brilliance of the whole thing.

Last edited by sundialsvcs; 11-13-2023 at 09:59 AM.
 
Old 11-13-2023, 01:10 AM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,879
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Quickstart:
https://xkcd.com/1597/
https://explainxkcd.com/wiki/index.php/1597:_Git
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to rename a branch, delete a branch, and find the author of a branch in Git LXer Syndicated Linux News 0 05-21-2022 02:33 AM
Couldnot switch from master branch to other stable branch in AOSP ayyasprings Linux - Mobile 2 01-20-2022 12:39 AM
LXer: Dev branch Fedora 32 versus Dev branch Ubuntu 20.04 in relation with KVM Hypervisor LXer Syndicated Linux News 0 03-20-2020 12:31 AM
Need Advice Concerning Testing Branch and Unstable Branch kevinbenko Debian 3 12-28-2017 06:45 AM
git branch changes are changing master? joejoe99 Linux - Software 2 05-01-2012 03:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration