https://github.com/sukhoy94/git-tips
Git tips/tricks and rules which I try to use in my everyday routine
https://github.com/sukhoy94/git-tips
cvs git git-flow git-tips teamwork
Last synced: about 1 month ago
JSON representation
Git tips/tricks and rules which I try to use in my everyday routine
- Host: GitHub
- URL: https://github.com/sukhoy94/git-tips
- Owner: sukhoy94
- Created: 2020-08-19T07:26:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-03T12:14:55.000Z (10 months ago)
- Last Synced: 2025-01-31T17:13:22.757Z (3 months ago)
- Topics: cvs, git, git-flow, git-tips, teamwork
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
https://marklodato.github.io/visual-git-guide/index-pl.html?no-svg
# git-tips
1. reset local branch to it's origin version
```
git fetch origin
git reset --hard origin/master
```2. reset file version to repository version
```
git checkout {branchname} -- {path-to-file}
```3. 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
4. Delete branch (locally and remote):
```
git push -d
git branch -d
```5. 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
```6. Create subbranch from branch
```
git checkout -b myFeature baseBranch
```7. Add alias for command:
```
git config --global alias.st status
```8. Get list of aliases:
```
git config --get-regexp alias
```9. cherry-pick but change commit message:
```
git cherry-pick -e
```10. Add remote to local repo:
```
git remote add origin [email protected]:User/UserRepo.git
git push -u origin master
```11. Change remote origin
```
git remote remove origin
git remote add origin ORIGIN_URL
```12. 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
```13. Reset all changed files to origin branch state
```
git checkout -- .
```14. See changes which is in main but not in my local branch:
```
git log HEAD..origin/main
```
## 3 important rules to work with GIT in team:
```
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.
```15. 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
```