Git diff against a stash

See the most recent stash: git stash show -p See an arbitrary stash: git stash show -p stash@{1} From the git stash manpages: By default, the command shows the diffstat, but it will accept any format known to git diff (e.g., git stash show -p stash@{1} to view the second most recent stash in patch … Read more

How can I reconcile detached HEAD with master/origin?

First, let’s clarify what HEAD is and what it means when it is detached. HEAD is the symbolic name for the currently checked out commit. When HEAD is not detached (the “normal”1 situation: you have a branch checked out), HEAD actually points to a branch’s “ref” and the branch points to the commit. HEAD is … Read more

How do I undo ‘git reset’?

Short answer: git reset ‘HEAD@{1}’ Long answer: Git keeps a log of all ref updates (e.g., checkout, reset, commit, merge). You can view it by typing: git reflog Somewhere in this list is the commit that you lost. Let’s say you just typed git reset HEAD~ and want to undo it. My reflog looks like … Read more

Git push requires username and password

A common cause is cloning using the default (HTTPS) instead of SSH. You can correct this by going to your repository, clicking “Clone or download”, then clicking the “Use SSH” button above the URL field and updating the URL of your origin remote like this: git remote set-url origin git@github.com:username/repo.git You can check if you … Read more

Pretty Git branch graphs

Update 2: I’ve posted an improved version of this answer to the Visualizing branch topology in Git question, since it’s far more appropriate there. That version includes lg3, which shows both the author and committer info, so you really should check it out. Leaving this answer for historical (& rep, I’ll admit) reasons, though I’m … Read more

How can I get a list of Git branches, ordered by most recent commit?

Use the –sort=-committerdate option of git for-each-ref; Also available since Git 2.7.0 for git branch: Basic Usage: git for-each-ref –sort=-committerdate refs/heads/ # Or using git branch (since version 2.7.0) git branch –sort=-committerdate # DESC git branch –sort=committerdate # ASC Result: Advanced Usage: git for-each-ref –sort=committerdate refs/heads/ –format=”%(HEAD) %(color:yellow)%(refname:short)%(color:reset) – %(color:red)%(objectname:short)%(color:reset) – %(contents:subject) – %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))” … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)