https://marklodato.github.io/visual-git-guide/index-pl.html?no-svg
- reset local branch to it's origin version
git fetch origin
git reset --hard origin/master
- reset file version to repository version
git checkout {branchname} -- {path-to-file}
- Check if base branch has ahead commits of subbranch
git rev-list --count branch1..basebranch
if return = 0, it means that there is no changes ahead
- Delete branch (locally and remote):
git push -d <remote_name> <branch_name>
git branch -d <branch_name>
- Cherry pick
Make sure you are on the branch you want to apply the commit to.
git checkout master
Execute the following:
git cherry-pick <commit-hash>
- Create subbranch from branch
git checkout -b myFeature baseBranch
- Add alias for command:
git config --global alias.st status
- Get list of aliases:
git config --get-regexp alias
- cherry-pick but change commit message:
git cherry-pick -e <hash>
- Add remote to local repo:
git remote add origin [email protected]:User/UserRepo.git
git push -u origin master
- Change remote origin
git remote remove origin
git remote add origin ORIGIN_URL
- My git aliases list:
git config --global alias.st status
git config --global alias.cmt commit
git config --global alias.p push
git config --global alias.a add
git config --global alias.co checkout
git config --global alias.pl pull
git config --global alias.mg merge
- Reset all changed files to origin branch state
git checkout -- .
- See changes which is in main but not in my local branch:
git log HEAD..origin/main
1. Resolve conflicts only when you understand why they have arisen.
2. Always check the list of commits you push
3. Notified all developers if you have done push force.
- change remote origin url
First - check current remote url
git remote -v
Second actual change:
git remote set-url origin [email protected]:myuser/my-project.git