Download the latest commits
git remote update -p
Update 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~1
Adds co-author to your commit message. Handy for pair programming.
Commit message
Co-authored-by: Joel Califa <602352+califa@users.noreply.github.com>
In order to not override someone else commits(with force) in remote repository use:
git push --force-with-lease
git reset HEAD~1
where ~1
is a number of commits from HEAD
# hard reset (loosing files/changes)
git reset --hard HEAD~1
# on a remote branch
git pull --rebase
# on a master
git pull --rebase origin master
# preview last stashed changes
git stash show -p stash@{0}
Create named stash with adding files with hunks preview
git stash push -p -m "my awesome config"
git checkout -- .
git checkout -
git commit --amend
To view a git log of just one user's commits:
git log --author="Alex"
Is useful to re-trigger CI pipeline or any other cloud integrations.
git commit --allow-empty -m "Trigger something"
git branch -m <newname>
git branch -m <oldname> <newname>
git config --global user.name "Alexander Grischuk"
git config --global user.email [your email address here]
git config --global pull.rebase true
is equivalent to running git pull --rebase
every time.
git config --global push.default current
echo ".idea" > ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
npx gitignore node
ssh-keygen -t rsa -b 4096
pbcopy < ~/.ssh/id_rsa.pub
Add following to the ~/.ssh/config
Host *
AddKeysToAgent yes
UseKeychain yes
ssh-add --apple-use-keychain ~/.ssh/<private_key>
git rebase origin/master
When the first conflict arises, I checkout the yarn.lock then re-perform the installation
git checkout origin/master -- yarn.lock
yarn
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:
git add yarn.lock
git rebase --continue
git tag <tagname>
git push origin --tags
git push origin <tag>
git tag
Get up to speed with partial clone and shallow clone
git prune --dry-run
git fetch --prune
git-reflog
- Manage reflog informationgit-bisect
- Use binary search to find the commit that introduced a bug