Git
How to avoid merge commits
Download the latest commits
git remote update -pUpdate the local branch
git merge --ff-only @{u}If the above fails with a complaint that the local branch has diverged:
git rebase -p @{u}
git reset --hard HEAD~1
git reset HEAD~1Add
Adds co-author to your commit message. Handy for pair programming.
Commit message
Co-authored-by: Joel Califa <602352+califa@users.noreply.github.com>Push
In order to not override someone else commits(with force) in remote repository use:
Reset
where ~1 is a number of commits from HEAD
Rebase
Stash
Create named stash with adding files with hunks preview
Checkout unwanted files
Checkout to previous branch
Edit last local commit message
Git log
To view a git log of just one user's commits:
Commit
Empty commit
Is useful to re-trigger CI pipeline or any other cloud integrations.
Branch
Rename a local Git branch
Rename a current branch
Rename a brach while pointed to any branch
Git global configurations
in ~/.gitconfig
To change your Git username and email
Enable git pull use rebase by default
is equivalent to running git pull --rebase every time.
~/.gitignore_global
Ignore IDEA files globally
Create a new .gitignore file fetched from the GitHub repo for a "node" js app
.gitignore file fetched from the GitHub repo for a "node" js appCreating a SSH Public Key on OSX
Copy public SSH key and add it to the GitHub
UseKeychain: do not re-enter password while commiting/clonning
Add following to the ~/.ssh/config
Add private key to keychain
Make sure AddKeysToAgent is set to yes in ~/.ssh/config for this to work
How to resolve conflicts in yarn.lock
https://github.com/yarnpkg/yarn/issues/1776#issuecomment-269539948
When the first conflict arises, I checkout the yarn.lock then re-perform the installation
This generates a new yarn.lock based on the origin/master version of yarn.lock, but including the changes I made to my package.json. Then it's just a matter of:
Release
Create a release tag
Push all tags
Push a single tag
List all tags
Clone
Get up to speed with partial clone and shallow clone
Clean up
clean unreachable object (sometimes speeds up .git)
clean outdated branches
Advanced git
git-reflog- Manage reflog informationgit-bisect- Use binary search to find the commit that introduced a bug
Further reading
Last updated
Was this helpful?