# Git tips

### Update  git version

* [Update tutorial for git mac installation](https://coolestguidesontheplanet.com/install-update-latest-version-git-mac-osx-10-9-mavericks/)

### Integrate a submodule into the parent repository

* [Saving the history](http://x3ro.de/2013/09/01/Integrating-a-submodule-into-the-parent-repository.html)
* [Without saving the history](http://stackoverflow.com/questions/1759587/un-submodule-a-git-submodule/1789374#1789374)
* [Using git stash effectively](https://www.atlassian.com/git/tutorials/git-stash#stashing-your-work)

### Git version

* `git --version` Display  the git version used

### Git undoing things

* <https://blog.github.com/2015-06-08-how-to-undo-almost-anything-with-git/>
* <https://www.atlassian.com/git/tutorials/undoing-changes>

### Rebasing in gitkraken

* <https://www.youtube.com/watch?v=-3yqteu-pLM>

### Change remote url without hacking .git/config file

* `git remote set-url origin https://wwwwgithub.com/awesome/awesome-project`

### Squash commits

* <https://github.com/wprig/wprig/wiki/How-to-squash-commits>

### What to do in case of problems with git&#x20;

* <https://ohshitgit.com/>

### Clean our local merged branch&#x20;

* <https://stevenharman.net/git-clean-delete-already-merged-branches>

### Reapply the change after a revert : Revert the revert&#x20;

* <https://www.drupaldump.com/gitlab-revert-reverted-merge>

### Mixing rebase and merge (occasionally)

It can be useful for example if the branch has many commits and we don't want to stash and prevent multiple fix conflicts \
it seems to be technically possible as explained in this issue

{% embed url="<https://stackoverflow.com/questions/42513943/what-happens-when-you-combine-git-merge-and-rebase>" %}

### Reference a library by a commit in package.json&#x20;

{% embed url="<https://stackoverflow.com/questions/14187956/npm-install-from-git-in-a-specific-version>" %}

### Undoing a rebase ! (after an error) even after you pushed to remote

{% embed url="<https://stackoverflow.com/questions/134882/undoing-a-git-rebase>" %}
