[R-pkg-devel] GitHub error
Ivan Krylov
kry|ov@r00t @end|ng |rom gm@||@com
Thu Apr 21 08:42:44 CEST 2022
В 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.
--
Best regards,
Ivan
[*]
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging
More information about the R-package-devel
mailing list