[R-pkg-devel] GitHub error
Spencer Graves
@pencer@gr@ve@ @end|ng |rom e||ect|vede|en@e@org
Thu Apr 21 11:12:02 CEST 2022
Hi, Ivan: Thanks for the reply. I actually added .DS_Store and another
file to .gitignore and ran "git rm -r --cached .DS_Store", etc., to
remove them from git coverage. When git wouldn't let me "git pull" and
"git push" to fix the problem on GitHub, I found those files in the
GitHub repository and manually removed them. That seemed to work, but I
found that those files were still listed as "Changes to be committed",
so I committed them. If I had done the commit earlier, I may not have
had to remove the files manually, but I don't know that. Thanks again.
Spencer
On 4/21/22 1:42 AM, Ivan Krylov wrote:
> В Wed, 20 Apr 2022 20:16:28 -0500
> Spencer Graves <spencer.graves using effectivedefense.org> пишет:
>
>> When I do "git pull", I get "error: Your local changes to
>> the following files would be overwritten by merge: .DS_Store
>> .gitignore inst/.DS_Store".
>
> Translating this back into human language, the histories tracked by
> your local copy of the Git repo and by GitHub have diverged. Locally,
> your macOS computer created a .DS_Store directory and performed some
> changes there (it's much better to avoid tracking it in Git, as it's
> useless to the consumers of the repository, and to list it in
> .gitignore), and you also changed .gitignore, but haven't committed
> those changes. On the GitHub side, you or some other contributor
> performed some changes to the same files and committed them. They might
> be the same changes, but Git refuses to overwrite local changes you
> haven't committed.
>
>> I've done "git rm --cached .DS_Store", etc., which some web page told
>> me would remove ".DS_Store" from GitHub but not from my local copy.
>
> You should probably (1) commit the changes you performed to the
> local copy so that git pull would proceed; (2) resolve any merge
> conflicts resulting from the inevitable merge; (3) git rm -r --cached
> .DS_Store from your repo and list .DS_Store in .gitignore; (4) commit
> your changes un-tracking .DS_Store and ignoring it from now on; (5) push
> them to GitHub.
>
>> Then when I try, "git push", I get "! [rejected] //
>> master -> master (non-fast-forward) // error: failed to push some
>> refs to 'github.com:JamesRamsay5/fda.git'".
>
> Since your "master" branches have diverged, GitHub will refuse to accept
> your commits that aren't created on top of GitHub's head of the
> "master" branch. git push --force *will* make the error go away, but it
> will also overwrite history and _lose the changes_ that GitHub had but
> your local copy of the repository did not.
>
> I can't give any links to good Git merging tutorials besides the Git
> Book [*], but when working with Git, it's really necessary to learn
> merging in order to avoid losing data to history rewrites by git push
> --force and the like.
>
More information about the R-package-devel
mailing list