Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

github - Git force push restoring old version to repo instead of new

I have a repo called WebScraper with a single branch called main. I am the sole contributor to the repo but do so from multiple machines. There is NO gitignore file. The program scrapes web data and updates a fairly small csv (<2k lines). It runs daily on machine1.

Currently on machine1 CSV was edited this morning (1/25) and I can verify there's new data as the last lines are dated 1/25. Currently on web repo CSV was updated on 1/23 and I can verify this as the last lines are dated 1/23.

Inside the WebScraper dir I use git push and get a 'Everything up-to-date' message. A. Why does it fail to recognize that CSV has been recently updated?

git push

Next I try deleting CSV from the web repo and retrying 'git push' on machine1. Machine1 commits some changes but the old 1/23 CSV appears on the web repo (verified via data inside).

B. Where is it getting the old CSV files from? How does it conjure a file into existence and then decide not to use the more recently modified version?

Next I try 'git push --force' from machine1. It goes through the enumerating, counting, delta compression, writing steps, says 100% done, gives comit numbers andsays --> main (forced update) BUT the CSV is still outdated.

git push --force
question from:https://stackoverflow.com/questions/65893424/git-force-push-restoring-old-version-to-repo-instead-of-new

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The problem was I had not commited the changes prior to attempting to push them. Confusion arouse because I had been used to using GUI git interfaces (gitkraken) where they have a 'Stage' button that essentially is the same as commit. So Switching from GUI to CLI I wasn't aware of the need to commit prior to pushing. Many thanks for the help.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...