{"id":22792815,"url":"https://github.com/johnantoni/git-notes","last_synced_at":"2026-01-08T13:31:11.003Z","repository":{"id":10268686,"uuid":"12381374","full_name":"johnantoni/git-notes","owner":"johnantoni","description":"git notes","archived":false,"fork":false,"pushed_at":"2014-03-13T15:33:19.000Z","size":216,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-05T19:09:08.663Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":false,"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/johnantoni.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}},"created_at":"2013-08-26T14:32:27.000Z","updated_at":"2014-03-13T15:33:19.000Z","dependencies_parsed_at":"2022-09-19T10:21:41.516Z","dependency_job_id":null,"html_url":"https://github.com/johnantoni/git-notes","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/johnantoni%2Fgit-notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnantoni%2Fgit-notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnantoni%2Fgit-notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnantoni%2Fgit-notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnantoni","download_url":"https://codeload.github.com/johnantoni/git-notes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246351016,"owners_count":20763232,"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":[],"created_at":"2024-12-12T03:16:20.938Z","updated_at":"2026-01-08T13:31:10.958Z","avatar_url":"https://github.com/johnantoni.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# GIT\n\n## Installing GIT Hooks\n\n    $ cd .git\n    $ rm -fr hooks\n    $ git clone git://github.com/zoocasa/git-hooks.git hooks \n\n## Common Development Tasks\n\n### Squash Commits\n\n    git rebase -i HEAD~3\n\n~3 = review last three commits\n\nDo your changes, the first commit message will be the title one, the rest will be below it, sub headings.\nOnce done, you'll need to rewrite the remote's history to keep everything in-sync so force-push it.\n\n    git push origin branch-name --force\n\nrewrite history on remote\n\n### discard all changes\n\n    git checkout -- .\n\n### List edits by who on what (blame)\n\n    git blame [filename]\n\n### Pruning Branches\n\n    git fetch --prune\n    git prune\n    git gc --aggressive\n\n### Fetching Remote Branches\n\n    git fetch --all\n\n### Create a new Branch based on the current commit\n\n    git co -b [new-branch-name]\n\n### Track Branch (git 1.8)\n\n    git branch -u origin/new-feature\n\n### Amend a Commit\n\n    git commit -m 'initial commit'\n    git add forgotten_file\n    git commit --amend\n\n### Ammend a Commit (rewriting remote branch's history)\n\n    git co HEAD~1\n    git commit -m 'forgotten file'\n    git push origin branch-name --force\n\n### Get all Changes from Parent branch\n\nSay you're on new-feature and you want to pull the changes from master\n\n##### First make sure your local master is up-to-date\n\n    git co master\n    git pull --rebase -p\n\n-p means prune any obsolete branches\n\n##### Now checkout your new-feature branch and pull the changes from master\n\n    git co new-feature\n    git rebase master\n\nWhen you rebase it will stop if there's merge conflicts introduced from master.\n\nIf you get any, fix them with your text editor then:\n\n##### Check what's been changed:\n\n    git status\n    git diff\n\nAdd your resolutions:\n\n    git add .\n\nContinue rebasing:\n\n    git rebase --continue\n\nIf nothing was changed with resolution:\n\n    git rebase --skip\n\nOnce resolved \u0026 rebased you will now be back on the new-feature branch with an updated commit history.\n\nTo push your changes to the branch you'll need to force-push as the history in the remote branch will be out of date.\n\n    git push -f origin new-feature\n    \n### Destroy your last commit?\n\nIf you accidentally committed something you wish you hadn't,\n\n    git reset --hard HEAD~1\n    \nrollback one commit\n\n    git push origin [branch-name] --force\n    \nforce push your branch overwriting the remote and wiping that commit from existence\n\nNOTE: best to do a git pull before even thinking about --force pushing your changes as you'll potentially wipe someone elses commits if you don't have them.\n\n### When to do a rebase / force-push\n\n* Before merging into the main branch\n* When reviving an old branch\n\n## Cherry Pick one commit into current branch\n\nFind the commit id for the one you want to apply to the top of your current branch, then:\n\n    git cherry-pick [commit hash]\n\nMore [here](http://ariejan.net/2010/06/10/cherry-picking-specific-commits-from-another-branch/)\n\n## Rollback Local to be same as Remote\n\n    git fetch origin\n    git reset --hard origin/master\n\n## Commands\n\n### git r\nshow current branch history\n\n### git ra\nshow all history\n\n### git push --set-upstream origin \u003cbranch-name\u003e\n*--set-upstream* sets what ref we'll be pushing to so we don't have to specify every time.\nThis won't have any effect as we've used [default=nothing] in our .gitconfig so we'll have to specify the ref on each push.\n\n### git pull --rebase\nDoing 'git pull' is fine but if you're working on a branch others are actively using this will add a merge message to the log messing up the log history. Using --rebase will do a pull then rebase and keep the log clean.\n\n### git stash\nStash your un-committed changes\n\n### git stash pop\nRestore your stashed changes\n\n### git stash list\nList all stashed changes\n\n### git stash pop[1]\nRestore stashed change at location 1\n\n### git merge --ff-only\nRefuse to merge and exit with a non-zero status unless the current HEAD is already up-to-date or the merge can be resolved as a fast-forward.\n\n### git branch -d \u003cbranch-name\u003e\nDelete local branch\n\n### git push origin --delete \u003cbranch-name\u003e\nDelete remote branch\n\n### git ri \u003cbranch-name\u003e\nStart interactive rebase\n\n### git rebase --abort\nAbort rebase\n\n### git reset --soft\nDoes not touch the index file nor the working tree at all (but resets the head to \u003ccommit\u003e, just like all modes do). This leaves all your changed files \"Changes to be committed\", as git status would put it.\n\n### git reset --hard\nResets the index and working tree. Any changes to tracked files in the working tree since \u003ccommit\u003e are discarded.\n\n### git reset --hard HEAD~3\nRewind branch 3 commits back, destroying those commits\n\n### git grep [search term]\nSearch committed code in a git repo http://stackoverflow.com/questions/2928584/how-to-grep-search-committed-code-in-the-git-history\n\n### git blame [file]\nSee commit history for file.\n\n### git branch -a\nSee both local and remote branches\n\n### git branch -l\nSee local branches\n\n### git branch -r\n\nSee remote branches\n\n### git submodule add\n\nAdd submodule\n\n    git submodule add git@github.com:johnantoni/git-notes.git docs/git-notes\n\n## Tools\n\n* TIG[https://github.com/jonas/tig]\n\n## Notes\n\n### Rebase Types\n\n    p, pick = use commit\n    r, reword = use commit, but edit the commit message\n    e, edit = use commit, but stop for amending\n    s, squash = use commit, but meld into previous commit\n    f, fixup = like \"squash\", but discard this commit's log message\n    x, exec = run command (the rest of the line) using shell\n\n## Links\n\n* [revert to previous commit](http://stackoverflow.com/questions/4114095/git-revert-to-previous-commit-how)\n* [25 Tips for Intermediate Git Users](http://andyjeffries.co.uk/articles/25-tips-for-intermediate-git-users)\n* [GitX for OSX](https://github.com/rowanj/gitx)\n\nBroken git pull location, edit .git/config\n* [http://stackoverflow.com/questions/13030714/git-1-8-0-fatal-the-current-branch-master-has-multiple-upstream-branches-refu](http://stackoverflow.com/questions/13030714/git-1-8-0-fatal-the-current-branch-master-has-multiple-upstream-branches-refu)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnantoni%2Fgit-notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnantoni%2Fgit-notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnantoni%2Fgit-notes/lists"}