git - 我丢失了 gitbash 之前的提交 github
问题描述
我正在使用 git bash 将我的项目更新到 github,但这没有更新,我尝试用谷歌搜索我的问题,然后通过使用一些命令将我的项目更新到 git hub 存储库,但我之前的提交不存在。
我没有删除我的项目,但是当我的项目没有更新时,我删除了隐藏目录的“git”目录。
我的命令我用过的。
182 git init
183 git add .
184 git commit -m "initial relese 3*3"
185 git branch -M main
186 git remote add origin https://github.com/sainivinit/TicTacToe.git
187 git push -u origin main
188 git push -u origin main -force
189 git push -u origin main --force
190 exit
191 git init
192 git add -A
193 git commit -m "working 10*10 or dynamic play board and shift hard to soft code"
194 git remote rm origin
195 git remote add origin https://github.com/sainivinit/TicTacToe.git
196 git push -u origin main
197 git init
198 git add -A
199 git commit -m "10*10 board solved some issue"
200 git remote rm origin
201 git remote add origin https://github.com/sainivinit/TicTacToe.git
202 git push -u origin main
203 exit
204 git init
205 git add .
206 git commit -m "initial realese"
207 git branch -M main
208 git remote add origin https://github.com/sainivinit/ShakshiTradres.git
209 git push -u origin main
210 git init
211 git add -A
212 git commit "10*10 board now playboard and players datasource is different"
213 git commit -m "10*10 board now playboard and players datasource is different"
214 git remote rm origin
215 git remote add origin https:///github.com/sainivinit/TicTacToe.git
216 git push -u origin main
217 git init
218 git add -A
219 git commit -m "10*10 board checkDiagonalsForWin"
220 git remote rm origin
221 git remote add origin https://github.com/sainivinit/TicTacToe.git
222 git push -u origin main
223 git init
224 git add -A
225 git commit -m "10*10 board now players will save in h2 and palyboard will save into mysql"
226 git remote rm origin
227 git remote add origin https://github.com/sainivinit/TicTacToe
228 git push -u origin main
229 exit
230 git init
231 git add -A
232 git commit -m "remove lots of bugs and use recomended pettern"
233 git remote rm origin
234 git remote add origin
235 git remote add origin https://github.com/sainivinit/TicTacToe.git
236 git push -u main
237 git push -u main --force
238 git remote add origin https://github.com/sainivinit/TicTacToe.git
239 git push -u origin main
240 git push -u origin main --force
241 exit
242 git init
243 git add -A
244 git commit -m "impletemns integration testing and solved some issue"
245 git remote rm origin
246 git remote add origin https://github.com/sainivinit/TicTacToe.git
247 git push -u origin main
248 git push -u origin main
249 git init
250 git add -A
251 git commit -m "complete game score"
252 git remote rm origin
253 git remote add origin https://github.com/sainivinit/TicTacToe.git
254 git push -u origin main
255 git clone https://github.com/sainivinit/TicTacToe.git
256 v
257 git init
258 git add -A
259 git commit "solved some issue"
260 git commit -m "solved some issue"
261 git remote rm origin
262 git remote add origin https://github.com/sainivinit/TicTacToe.git
263 git push -u origin main
264 exit
265 git init
266 git add -A
267 git commit -m "integration testing"
268 git remote rm origin
269 git remote add origin https://github.com/sainivinit/TicTacToe.git
270 git push -u main
271 git remote add origin https://github.com/sainivinit/TicTacToe.git
272 git push -u main
273 git remote add https://github.com/sainivinit/TicTacToe.git
274 git remote add origin https://github.com/sainivinit/TicTacToe.git
275 git push -u main
276 git push -u main --force
277 git init
278 git add -A
279 git commit -m "integration testing"
280 git remote rm origin
281 git remote add https://github.com/sainivinit/TicTacToe.git
282 git remote add origin https://github.com/sainivinit/TicTacToe.git
283 git push -u origin main
284 git push -u origin main
285 git init
286 git add -A
287 git commit -m "integration testing & solve some issue"
288 git remote rm origin
289 git remote add origin https://github.com/sainivinit/TicTacToe.git
290 git push -u origin main
291 git init
292 git add -A
293 git commit -m "integration testing"
294 git remote rm origin
295 git remote rm origin
296 git remote add origin https://github.com/sainivinit/TicTacToe
297 git push -u origin main
298 git remote add origin https://github.com/sainivinit/TicTacToe.git
299 git push -u origin main
300 git push -u origin main --force
301 git push -u origin master
302 git show-ref
303 git push origin HEAD:main
304 git show-ref
305 git push -u origin main
306 git push origin HEAD:main
307 git init
308 git add .
309 git commit -m "integration testing"
310 git push -u origin master
311 git push -u origin master --force
312 git push -u origin master --force
313 git init
314 git add -A
315 git commit -m "test integration"
316 git push origin HEAD:main
317 git push origin HEAD:main --force
318 git commit -m "test integration"
319 git reflog
320 git reflog
321 history
我已经失去了我之前的 11 次提交。
解决方案
为什么您的历史记录被删除:
该.git/
目录包含本地克隆的所有 git 数据库。如果删除该目录,则会删除所有退出分支、提交和 reflog 的跟踪。
如果您随后运行git init
,git commit
您将创建一个新的历史记录,其中包含一个提交(并且没有先前存在的提交的痕迹)。
使用这样的历史记录运行git push --force
将指示 git 用该单一提交替换远程分支。
所以:您删除了本地 reflog(删除时.git/
)并删除了远程历史记录(运行时git push -f
)。
你可以做些什么来恢复它:
您将不得不查看 github 的 reflog。你不能通过 git 直接访问它,但是有一些方法可以通过 github 的 api 访问它。
例如尝试这篇文章中建议的命令:
推荐阅读
- xml - 为 XML 命名空间前缀使用不同的名称是否重要?
- javascript - InvalidValueError: not an instance of HTMLInputElement - Google Autocomplete with Wordpress
- javascript - 如何在我的汽车销售网站上创建可扩展的“查看”按钮?
- java - 如何尝试使用 jtextfield 捕获异常?
- pdf - 从 guriddo jqgrid 导出 pdf 时如何添加徽标?
- java - 如何有效地将 100 万个对象写入 CSV 文件?
- java - 如何获取自定义文件未找到消息
- typescript - 如何为两个枚举创建映射类型?
- java - 减少SpringBoot可执行jar Angular App的磁盘空间
- scala - Scala 非致命示例