Github Site shows deleted commit in the commit tab - github

I am new to github commands and I am a bit confused about what I am doing.
I want to delete the "MegaMan Game" commit, revert all changes, and make it dissapear from github
history. Following this other stack overflow question Delete commits from a branch in Git, I ran the git reset --hard HEAD ~1 command. The commit seems to be deleted judging by the git log command, but on the github website it still shows that the "MegaMan Game" commit is still there. Also in source tree happens the same thing. The commit still shows there.
I am a bit confused. Is the website wrong about the commits? Did I run the command wrong?
Here is an image with the exact commands and what git
This is a noob question. I need help to undestand how this works.

You deleted commit in your local branch. You must send this change to the upstream branch(to github).
git push --force

Related

Can't to push commits from local branch to github repository

I was committing and pushing in ordinary for my repository.
but once i used command of git checkout for change to the previous version of my repository.
after that i tried to commit and push, then it can not completed.
i try to use the --no-verify command to push the commit but it also not success.
error: failed to push some refs to 'https://github.com/ruwanliyanage123/Hair-4-U-Hospital.git'
i want to push my commit into github repository
Since you switched to a previous version of your repository, your head is most probably detached. You can't just go back anywhere in your history and make commits.
Consider making a branch from there and then commit to it.
Try to first check in which branch you are working do git branch, check is the one you are working. Then I sometimes do git pull to just make sure that the connection is working this should not delete your progress the you should be able to do git push. If you are afraid youll mess up first do a local back up of all project files except for the .git one which are hidden by default in windows.Lastly I would suggest never posting the actual link to your github repository in case whatever you are working is important, you can just replace with
https://github.com/user/projectname.git

get previous commit that got deleted on git repository

Yesterday when I was at work, I was working on my project that i have on my home computer. The problem was when I tried cloning the repo it eclipse would crash. So instead I downloaded it manually and initialized the repo and then force pushed to my home computer. This deleted all the history and files in on the repo. I did some googling and tried reverting the commit but it the force push erased the commit history so I can only go back to the force push commit.
I have a computer at home which hasn't pulled the updates since this mistake and I was able to get its commit SHA. I used that on the web and found the last version its still there but I can't pull that commit because it got "deleted" and won't show in the repos history. Is there a way I can use the SHA from the last good commit and make that the master branch restoring my history?
When changing the HEAD (the working position in the git repository), it tracks your history in the reflog. Executing git reflog in the command line will show your complete history. You can read more about it on git-scm.com
When you have the desired commit SHA, you can do a git checkout with it. Executing git checkout [SHA1] will take you to the desired position in the git history. From there, you can make a new branch from it by running git checkout -b "new_branchname".
If you want to set your current branch to the commit, you can run git reset --hard [SHA1]. This would reset the current branch, but the previous state can however be found in the reflog.
I do NOT recommend doing this as general practice BUT...You should be able to force push from the other computer, thus resetting the repo to its former state. Providing you don't want to keep anything you did while making a giant mess of your git repo yesterday.
Since you know the right version you want to recover, it will make things easier.
In your local repo, use below commands:
git reset --hard <commit sha value>
git push -f
Note: if you execute the commands in the local not initialized (not cloned from remote), you should fetch first by git fetch --all, and then execute the two commands .
Now the version will go back to the latest as you need both locally and remotely.

Lost a bunch of code in Github, mistakingly reverted to an old push, what are my options?

The commit no longer shows up but rather the latest one now is the one named "Instructions work".
https://images.discordapp.net/.eJwFwQEOwiAMAMC_8ABahqNlv2mYcUYpy9plica_e_cN5_EOS9jcd1sA1qe1cazRcpQun6FyWWyjg7hL2_pd3aAWKnijMuGMzFQYEiYkToyUa5pznRBOfem4NO76CL8_2w8gBg.u1qWiqmlxQgWvh_ROTa4VHx2gCY.png?format=webp
That's the screenshot of my commit. I had a merge error and googled how to resolve it and did it. Didn't notice my commit disappeared. Pressed sync thinking i was pushing my commit. Actually reverted and my commits are gone.
git revertshouldn't do anything except create a new commit -- you should be able to undo the revert by reverting to head with git revert HEAD
EDIT:
You can also search for dangling commit blobs in your lost and found history using git fsck --lost-found and then find the one you want and then apply the commit with git merge <SHA1 of commit>.
You can try reverting the actual revert commit.

Connect an issue with a commit after the commit

I did a git commit and pushed to github, but forgot to mention the issue number in the commit (I forgot to write something like ... closes #123).
If I had mentioned the issue number in the commit message, github would have connected the commit to the issue. Is there any way to do this after the commit, when it's too late for me to change the commit message?
EDIT: Assume that it's too late to amend the commit or otherwise alter the history. I am really asking about github functionality, not git.
In your issue on GitHub, just write a comment with the commit hash. For instance:
Fixed with commit 61d949320fc0bf1a8dba09b3845bddcd153b1a64
GitHub will recognize it as a SHA and link to the right commit page.
The Github help page "Can I delete a commit message?" explain how to alter:
a commit you just pushed
older commits message
But since it changes the history, you need to make anyone having already pulled from the GitHub repo aware of that change.
If rewriting the history isn't possible, you can make a new commit, with a commit message including:
the close issue
the SHA1 of the previous commit.
GitHub will automatically link that old commit in your new commit message: see for istance the reference to commit cdfd948 in this git commit.

Get lost commits on GIT

Me and my partners are working on the git remote and both have write access to the remote.
He did some changes, commited them and pushed them to remote,
I did few changes in my machine and without fetching/pulling just force pushed my commits.
Which in turn resulted in lost of the commits of my partner.
So I have 2 questions:
1. Is there any way to get those commits back?
2. After my push, will my partners fetch, pull remove the changes he did, from his machine as well?
If you push commits that overwrite someone else's code, and didn't pull; git will throw an error something like this:
error: failed to push some refs to 'git#github.com:foo'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'non-fast forward'
section of 'git push --help' for details.
On the off chance that you actually did overwrite something, you can revert your entire git repo. See this stack overflow question for an example:
How do I restore files to previous states in git?