{"id":15877506,"url":"https://github.com/max-lobur/git-tips","last_synced_at":"2025-06-20T12:34:52.624Z","repository":{"id":93834098,"uuid":"80627845","full_name":"max-lobur/git-tips","owner":"max-lobur","description":"Various tips pinned from Pro Git (never gets old)","archived":false,"fork":false,"pushed_at":"2017-07-01T21:39:55.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-03T03:09:01.295Z","etag":null,"topics":["git","tips","tips-and-tricks","tutorials"],"latest_commit_sha":null,"homepage":"https://git-scm.com/book/en/v2","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/max-lobur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-02-01T14:29:30.000Z","updated_at":"2021-01-12T19:00:34.000Z","dependencies_parsed_at":"2023-06-15T07:30:19.974Z","dependency_job_id":null,"html_url":"https://github.com/max-lobur/git-tips","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/max-lobur/git-tips","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max-lobur%2Fgit-tips","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max-lobur%2Fgit-tips/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max-lobur%2Fgit-tips/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max-lobur%2Fgit-tips/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/max-lobur","download_url":"https://codeload.github.com/max-lobur/git-tips/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max-lobur%2Fgit-tips/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260945437,"owners_count":23087013,"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":["git","tips","tips-and-tricks","tutorials"],"created_at":"2024-10-06T02:01:39.820Z","updated_at":"2025-06-20T12:34:47.608Z","avatar_url":"https://github.com/max-lobur.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"### Tips saved while reading [Pro Git](https://git-scm.com/book/en/v2):\n\n```\ngit diff \t\t\t: compare current with staged (or with last commit if no staged one)\ngit diff —staged \t\t: compare staged with last commit\ngit diff \u003cmaster\u003e…\u003ctopicbr\u003e\t: show diff introduced by topicbr comparing to master (base commit in master)\ngit diff \u003csha-1\u003e\t\t: show diff betwheen latest commit of current branch and other commit (sha-1)\n\ngit log -n \t\t\t: view last n commits\ngit log -n -p \t\t\t: last n commits with summary of changes (diff)\ngit log -n —graph\t\t: graphical view branch history\ngit log —pretty=oneline\t\t: each commit at one line\ngit log \u003cbr1\u003e —not \u003cbr2\u003e\t: list commits which are in br1 but not in br2\ngit log \u003cbr1\u003e \u003cbr2\u003e —not \u003cbr3\u003e \t: list commits which are in br1 and br2 but not br3\ngit log \u003cmaster\u003e..\u003ctopicbr\u003e \t: show commits that reachable from topic but not from master (—||—)\ngit log origin/master..HEAD \t: show what will be pushed to remote in case of push (—||—)\ngit log \u003cmaster\u003e…\u003ctopic\u003e\t: show commits not reachable from both branches semitaneousely (not shared)\ngit log —left-right \u003cmaster\u003e…\u003ctopic\u003e : same to previous, but show which commit at which branch\n\ngit remote -v \t\t\t: list remotes\ngit remote add \u003cname\u003e \u003curl\u003e\t: add remote\ngit remote show [remote]\t: details of remote\ngit remote rename \u003cold\u003e \u003cnew\u003e\t: rename remote\ngit remote rm \u003cremote\u003e\t\t: delete remote reference\n\ngit reset HEAD [file]\t\t: unstage file or all files\ngit checkout — [file | *]\t: revert unstaged file (* for all files) to last commit state\nreset HEAD; checkout * \t\t: revert all the changes in current branch\ngit reset --hard origin/master  : revert to remote state\n\ngit checkout -b \u003cbranch\u003e\t\t\t: make a new branch basing on current\ngit checkout -b \u003cbranch\u003e \u003cremote\u003e/\u003crmtbranch\u003e \t: make a local copy of branch fetched from remote (tracking copy)\ngit checkout -—track \u003cremote\u003e/\u003crmtbranch\u003e\t: —||— \ngit checkout -b \u003cbranch\u003e \u003csha-1\u003e \t\t: make a new branch basing on some commit and switch to it\ngit checkout -b \u003cbranch\u003e \u003cbasebrsanch\u003e\t\t: make a new branch basing on other branch and switch to it\n\ngit branch -d \u003cbranch\u003e \t: delete branch\ngit branch -v \t\t: list branches with last commit for each\ngit branch —merged\t: list branches merged to current (can be deleted)\ngit branch —no-merged \t: list all not merged to current\n\ngit fetch [remote]\t\t\t\t: get data from remote (not merge with local)\ngit pull [remote]\t\t\t\t: get data from remote and merge into local\ngit push [remote] [branch]\t\t\t: send branch state to remote\ngit push [remote] [\u003clocalbranch\u003e:\u003cremotebranch\u003e] \t: same but with diff name of remote branch \ngit push \u003cremote\u003e :\u003cremotebranch\u003e\t\t \t: remove branch on remote server\n\ngit tag \t\t\t: list all available tags\ngit tag -l “*”\t\t\t: filter tags by pattern\ngit tag \u003cname\u003e\t\t\t: create lightweight tag for last commit\ngit tag \u003cname\u003e \u003csha-1\u003e\t\t: create tag for not the latest commit\ngit tag -a \u003cname\u003e -m \u003cmsg\u003e\t: create annotated tag (-s instead -a --\u003e signed tag)\ngit show \u003ctag name\u003e\t\t: show commit marked by tag, and tag’s info\ngit tag -v \u003ctag name\u003e\t\t: verify signed tag\ngit push \u003cremote\u003e \u003ctag\u003e\t\t: push tag to remote\ngit push \u003cremote\u003e —tags \t: push all tags to remote\ngit describe [branch]\t\t: get current branch state (latest tag + number of commits after); kind of build number\n\ngit merge \u003cbranch\u003e\t\t\t: merge specified branch into current\ngit rebase \u003cbranch\u003e\t\t\t: rebase current branch to the latest commit of \u003cbranch\u003e\ngit rebase —onto \u003ctarbr\u003e \u003cbr1\u003e\u003cbr2\u003e\t: rebase br2 from br1 to latest tarbr separately from any changes made within br1\ngit rebase -i HEAD~3 \t\t\t: change last 3 commits (like amend but for n commits)\nDO NOT rebase commits that were pushed to remote!\n \ngit merge-base \u003cbr1\u003e \u003cbr2\u003e \t: show common ancestor of the two branches\n \ngit cherry-pick \u003csha-1\u003e \t: rebase specified commit to the top of current branch\n \ngit stash \t\t\t: save all uncommitted changes from current branch and clear branch to not changed\ngit stash list\t\t\t: list stashes\ngit stash apply [stash@{n}]\t: apply latest stash if not specified, apply n-th stash otherwise\ngit stash apply \u003cst\u003e —index\t: apply latest stash including “staged” states of the files\ngit stash drop \u003cst\u003e\t\t: delete stash\nstash -\u003e checkout another branch -\u003e stash apply : move changes from one branch to another\ngit stash branch \u003cnewbranch\u003e\t\t\t: make a new branch from stash and remove stash\n \ngit filter-branch —tree-filter ‘\u003ccmd\u003e’ HEAD [—all]\t: apply ‘cmd' to each commit in current branch or all branches\n \ngit blame \t: annotate the file\ngit bisect \t: interactive binary search of the commit that introduced a bug\n \ngit config —global core.excludesfile \u003csome_gitignore\u003e \t: set common .gitignore for all files\ngit config —global color.ui true\t\t\t: colour output\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmax-lobur%2Fgit-tips","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmax-lobur%2Fgit-tips","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmax-lobur%2Fgit-tips/lists"}