How to remove unsynced commits in github for windows? - github

I have two unsynced commits using GitHub (Windows), but don't want to commit them now. How can I revert or drop them?

As mentioned in "How to reach some commands on Github for windows", you best course of action would be to use to git CLI (command line interface), opening a shell from "GitHub for Windows", or using msysgit.
Then a git reset HEAD^2 (or even git reset --hard HEAD^2 if you really want to remove those files as well as any work in progress) would drop those commits (as in "How do I delete unpushed git commits?" or "How to delete a 'git commit'").
After a refresh, GitHub for Windows should display no more unsynced commit.
Other answers below mention the recent addition of "Undo most recent commit", which achieve the same reset:
As I mentioned in "GitHub undo a discard", the "discard changes" feature would achieve the same as a git reset.

In the newest version of GitHub (Windows) under the Settings button, next to the "Sync" icon/button there is the option "Undo most recent commit", that will take care of those unsynced commits.

Latest version of GitHUb for Windows have this option. The option will be enabled in case you have any unsynced commit. This is a very useful update from GitHub.

There is an undo button. Right click on the file to commit and select "Discard changes".
https://github.com/blog/1441-undo-button-in-github-for-windows

I would suggest, based on the way the questions is phrased, and what searches it comes up for, that people may want to use "FETCH_HEAD when resetting via the git CLI/ ("Open in Git Shell") in the GitHub for Windows menu.
Once in the shell, run:
git reset FETCH_HEAD --hard
This will reset you back to where you were when you last pulled down changes from your remote - which is what it seems like some people hitting this page are looking to do.

Related

Github Site shows deleted commit in the commit tab

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

Commit message with --no-verify with git kraken

I want to ignore git hook in some scenario i have.
How can i commit using gitKraken while specifying --no-verify flag.
Thanks.
Unfortunately, it is not currently possible: https://twitter.com/GitKraken/status/1067485533738196992
It is possible as of GitKraken 9.1. https://help.gitkraken.com/gitkraken-client/current/#bypass-git-hooks.
There is a little arrow at the far-right of commit button that opens a popup where you can select "Commit and skip hooks"

Eclipse Egit. Checkout creates new commit. Why?

As I understand GIT, when I checkout on commit, I should get its files copy in my work directory, but no new commit should appear. Though when I use EGit and checkout on commit I see new commit in reflog. Why? As I understand checkout should not create new commit. Right?
Here I right click on commit and choose checkout
Then I get new commit in reflog:
So now I have few commits in my local master, but I never asked to do them.
Git integration for Eclipse - Task focused interface 4.6.1.201703071140-r org.eclipse.egit.mylyn.feature.group Eclipse EGit
You have to work with the History view instead of with the Git Reflog view (see git reflog and toniedzwiedz's answer for details):
Tell the History view which history should be shown: e. g. in Git Repositories view right-click a repository and choose: Show In > History.
In the History view enable the option Show All Branches and Tags (right button in the view toolbar). Otherwise, only commits of the current branch are displayed.
You don't see a new commit in the reflog. What you see is an updated position of HEAD. You changed it to commit 4b0d96a when you checked it out. When you check out another commit, branch or a tag, you'll see yet another entry appear in the reflog.
Try switching between two branches repeatedly and you'll see the same two commit hashes appended to the reflog again and again. This does not mean you're creating new commits. You just see existing commits being logged as recent commits pointed to by the HEAD pointer.
From the git reflog docs:
This command manages the information recorded in the reflogs.
The "show" subcommand (which is also the default, in the absence of any subcommands) shows the log of the reference provided in the command-line (or HEAD, by default). The reflog covers all recent actions, and in addition the HEAD reflog records branch switching. git reflog show is an alias for git log -g --abbrev-commit --pretty=oneline; see git-log for more information.
You may also find this chapter of the Pro Git book interesting. It offers a more comprehensible description of what git reflog does.

Revert git repository to prior commit using Github GUI

While there is loads of information available on how to revert to a specific commit using the git command line - e.g. How to revert Git repository to a previous commit?
Is there a way to achieve same using the github gui? There is a feature to revert the latest commit. However I was unable to find options from the Commits history to revert to a specific commit in the list:
on the right and here is what we see:
so there is no feature shown here for Revert to this commit.
Jump to the PR which is included in the commit which is to be reverted. Go to conversation section, there you will see revert option in front of all commits included in that PR (screenshot)
You can press the button on the side < > (like in your first picture) and with this you can browse the repository at the time after this commit. Now you can create a pull request or you can download the repository at this very point in time.
I guess there is no other solution if you really want to achieve this in the browser. In GitHub desktop there is the Revert button for each of your commits (screenshot).

In GitHub for Windows, why can't I see all of my commits to the current branch in the current branch's history?

I'm using the official GitHub for Windows client (http://windows.github.com/). I have been steadily committing changes to the branch "modeling-users", but I am unable to see many of my recent changes in the history for the current branch. I can see these commits by entering "git log" at the command prompt. I also looked at the commit history for this branch on the GitHub website. It shows the same incomplete commit history. Why isn't it showing all of my commits?
Image here: http://tinypic.com/r/maza7o/6
As anonymous user commented, GitHub for Windows can take time to reflect updates to repositories. The commits will eventually appear in GitHub for Windows.