Git Problems: Difference between revisions
Jump to navigation
Jump to search
(7 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
* [[Git]] | * [[Git]] | ||
* [[git | * [[git reset]] | ||
=Overview= | |||
=Local and Remote Origin Branches Have Diverged without Activity on Local Branch= | =Local and Remote Origin Branches Have Diverged without Activity on Local Branch= | ||
<font size=-1> | |||
> git status | > git status | ||
On branch hq_sep | On branch hq_sep | ||
Line 12: | Line 14: | ||
(use "git pull" to merge the remote branch into yours) | (use "git pull" to merge the remote branch into yours) | ||
nothing to commit, working tree clean | nothing to commit, working tree clean | ||
</font> | |||
If there is no activity on the local branch, and this message shows up, the only explanation is that history was rewritten on the remote branch. | If there is no activity on the local branch, and this message shows up, the only explanation is that history was rewritten on the remote branch. | ||
The solution is to throw away local "changes" - this implies we are absolutely sure we did not interact with the local branch and we did not apply useful changes, and get in sync with the remote origin: | The solution is to throw away local "changes" - this implies we are absolutely sure we did not interact with the local branch and we did not apply useful changes, and get in sync with the remote origin: | ||
<font size=-1> | |||
# be on the local branch | # be on the local branch | ||
[[git reset#Use_Cases|git reset]] --hard origin/''<remote-origin-branch>'' | [[git reset#Use_Cases|git reset]] --hard origin/''<remote-origin-branch>'' | ||
[[git reset#Use_Cases|git reset]] --hard origin/hq_sep | [[git reset#Use_Cases|git reset]] --hard origin/hq_sep | ||
</font> | |||
=Files Missing from Repository and Not Being Tracked= | |||
See: | |||
{{Internal|.gitignore|.gitignore}} | |||
{{Internal|Git check-ingore|git check-ignore}} | |||
Also git won't add empty directories or directories that only contain ignored files: | |||
{{Internal|Git add|git add}} |
Latest revision as of 07:38, 6 September 2021
Internal
Overview
Local and Remote Origin Branches Have Diverged without Activity on Local Branch
> git status On branch hq_sep Your branch and 'origin/hq_sep' have diverged, and have 25 and 61 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean
If there is no activity on the local branch, and this message shows up, the only explanation is that history was rewritten on the remote branch.
The solution is to throw away local "changes" - this implies we are absolutely sure we did not interact with the local branch and we did not apply useful changes, and get in sync with the remote origin:
# be on the local branch git reset --hard origin/<remote-origin-branch>
git reset --hard origin/hq_sep
Files Missing from Repository and Not Being Tracked
See:
Also git won't add empty directories or directories that only contain ignored files: