删除已推送但失败的Git Commit

时间:2017-04-23 00:07:53

标签: git github

我有2个脏提交,我需要摆脱它。当我做下面的git状态是我得到的:

$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        deleted:    Finals/Analysis/.ipynb_checkpoints/Analysis 3-checkpoint.ipynb
        deleted:    Finals/Analysis/Analysis 1.ipynb
        deleted:    Finals/Analysis/Analysis 2.ipynb
        deleted:    Finals/Analysis/Analysis 3.ipynb
        deleted:    Finals/Analysis/Analysis3_Image/wordcloud.png
        deleted:    Finals/Analysis/Download API Data.ipynb

no changes added to commit (use "git add" and/or "git commit -a")

我尝试了git reset --hard origin/master,持续了半个小时,什么也没做。

拜托,有人可以帮忙吗? 我有我的文件的备份,我很好,如果我也可以在线克隆到我的GITHUB目录。

4 个答案:

答案 0 :(得分:1)

git rebase -i

然后删除为我工作的提交。

感谢您的回复!有一个好的!

答案 1 :(得分:0)

如果您尚未完成git push以将更改发送到服务器,则可以删除本地文件并再次从服务器克隆。

答案 2 :(得分:0)

如果你已经推了它,那么我的建议就是尝试强制推动(这个名字好吗?)

git push origin HEAD --force

答案 3 :(得分:0)

let cell = tableView.cellForRow(at: indexPath) as! cell let theUsersID = cell.theObjectID.text! PFUser.current()?.addUniqueObjects(from: [theUsersID], forKey: "friendList") PFUser.current()?.saveInBackground() PFUser.current()?.removeObjects(in: [theUsersID], forKey: "blockFriend") PFUser.current()?.saveInBackground() self.usernames.remove(at: indexPath.row) tableView.deleteRows(at: [indexPath], with: .fade) 应该可以解决问题。