{"id":22367165,"url":"https://github.com/sukhoy94/git-tips","last_synced_at":"2025-03-26T15:51:58.462Z","repository":{"id":117094560,"uuid":"288663544","full_name":"sukhoy94/git-tips","owner":"sukhoy94","description":"Git tips/tricks and rules which I try to use in my everyday routine","archived":false,"fork":false,"pushed_at":"2024-07-03T12:14:55.000Z","size":27,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T17:13:22.757Z","etag":null,"topics":["cvs","git","git-flow","git-tips","teamwork"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sukhoy94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-19T07:26:20.000Z","updated_at":"2024-07-03T12:14:58.000Z","dependencies_parsed_at":"2025-01-31T17:13:15.529Z","dependency_job_id":"e2469c5d-d612-47e2-bdc9-eac411522488","html_url":"https://github.com/sukhoy94/git-tips","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukhoy94%2Fgit-tips","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukhoy94%2Fgit-tips/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukhoy94%2Fgit-tips/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukhoy94%2Fgit-tips/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sukhoy94","download_url":"https://codeload.github.com/sukhoy94/git-tips/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245689452,"owners_count":20656414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cvs","git","git-flow","git-tips","teamwork"],"created_at":"2024-12-04T18:16:37.902Z","updated_at":"2025-03-26T15:51:58.442Z","avatar_url":"https://github.com/sukhoy94.png","language":null,"readme":"https://marklodato.github.io/visual-git-guide/index-pl.html?no-svg\n\n# git-tips\n\n1. reset local branch to it's origin version\n```\ngit fetch origin\ngit reset --hard origin/master\n```\n\n2. reset file version to repository version\n\n```\ngit checkout {branchname} -- {path-to-file}\n```\n\n\n3. Check if base branch has ahead commits of subbranch\n\n```\ngit rev-list --count branch1..basebranch\n```\n\nif return = 0, it means that there is no changes ahead\n\n\n4. Delete branch (locally and remote): \n\n```\ngit push -d \u003cremote_name\u003e \u003cbranch_name\u003e\ngit branch -d \u003cbranch_name\u003e\n```\n\n5. Cherry pick\n\nMake sure you are on the branch you want to apply the commit to.\n```\ngit checkout master\n```\n\nExecute the following:\n```\ngit cherry-pick \u003ccommit-hash\u003e\n```\n\n6. Create subbranch from branch\n\n```\ngit checkout -b myFeature baseBranch\n```\n\n7. Add alias for command: \n\n```\ngit config --global alias.st status\n```\n\n8. Get list of aliases: \n\n```\ngit config --get-regexp alias\n```\n\n9. cherry-pick but change commit message: \n\n```\ngit cherry-pick -e \u003chash\u003e\n```\n\n10. Add remote to local repo: \n\n```\ngit remote add origin git@github.com:User/UserRepo.git\ngit push -u origin master\n```\n\n11. Change remote origin\n\n```\ngit remote remove origin\ngit remote add origin ORIGIN_URL\n```\n\n12. My git aliases list:\n\n```\ngit config --global alias.st status\ngit config --global alias.cmt commit\ngit config --global alias.p push\ngit config --global alias.a add\ngit config --global alias.co checkout\ngit config --global alias.pl pull\ngit config --global alias.mg merge\n```\n\n13. Reset all changed files to origin branch state\n\n```\ngit checkout -- .\n```\n\n14. See changes which is in main but not in my local branch:\n    ```\n    git log HEAD..origin/main\n    ```\n## 3 important rules to work with GIT in team: \n```\n1. Resolve conflicts only when you understand why they have arisen.\n2. Always check the list of commits you push\n3. Notified all developers if you have done push force.\n```\n\n15. change remote origin url\n\nFirst - check current remote url\n```\ngit remote -v\n```\nSecond actual change:\n```\ngit remote set-url origin git@github.com:myuser/my-project.git\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsukhoy94%2Fgit-tips","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsukhoy94%2Fgit-tips","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsukhoy94%2Fgit-tips/lists"}