Quickly create patch files from fixed contrib modules

You fixed something in contrib module and you want to create quick patch from that, if it spans through multiple commits, best way to do that is to make a patch from multiple commits, to combine them into one file, write this

GitLab revert the reverted merge

So you made a mistake and made a revert, then you want to introduce again the code you use in new merge, if you try to make merge request(MR) from branch you made original MR you reverted you will get nothing in that MR. This is not a bug, but a feature of git. Reverting does not roll back, but rather appends the revert to the front of the HEAD.

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.