git stash error: unable to unlink old (Permission denied)

When you try to git stash and get some error like "error: unable to unlink old" with permission denied with it, it is at is says permission problem, but not on that file, but directory where that file is.  So go to that folder where the problematic file is (usually it will be default folder) and give that folder permissions to write for user and group.

Add GIT branch to terminal prompt, works in your IDE also (PHPSTORM)

# Git branch in prompt.

parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "

So open ~/.bash_profile in your favorite editor and add the above content to the bottom.

Rebasing commits to amend or group commits

So you made some mistake with your previous commit but dont want to make hundreds of commits and want to have nice looking reflog. You can do some rebasing with this command

Adding existing project to git

When I was new to GIT this scared me, I was afraid I could somehow delete my current project or something like that, but it is rather trivial to add new GIT repo to existing project. All you need to do is add a remote config and do some initializations. Basically you do this

Using GIT with drupal7, do not put core into GIT

This is tutorial how to setup a drupal 7 site with git but without putting drupal core into git, reason is that you don't need it in git unless you are patching core. As drupal core is always the same and updated with drush, version control is not needed at least there is a stream of opinion that goes into that direction.  So what do you do, you only put sites folder into git.

GIT - reseting hard, moving to previous commit after merge

git reset --hard c517b565b2bcc0cf2ca5265b6ea6657f253fe2af
git push -f

to move git to previous commit and push it to remote server, we first need to reset hard to SHA value and then push it with force to overide current state