{"id":19324688,"url":"https://github.com/soarez/git-talk","last_synced_at":"2026-02-22T09:03:29.334Z","repository":{"id":5791562,"uuid":"7005840","full_name":"soarez/git-talk","owner":"soarez","description":null,"archived":false,"fork":false,"pushed_at":"2012-12-04T19:47:40.000Z","size":101,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T10:27:27.129Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/soarez.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":"2012-12-04T19:46:56.000Z","updated_at":"2014-05-01T05:52:31.000Z","dependencies_parsed_at":"2022-09-04T20:23:06.935Z","dependency_job_id":null,"html_url":"https://github.com/soarez/git-talk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/soarez/git-talk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soarez%2Fgit-talk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soarez%2Fgit-talk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soarez%2Fgit-talk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soarez%2Fgit-talk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soarez","download_url":"https://codeload.github.com/soarez/git-talk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soarez%2Fgit-talk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29707521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T05:59:28.568Z","status":"ssl_error","status_checked_at":"2026-02-22T05:58:46.208Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-10T02:06:26.368Z","updated_at":"2026-02-22T09:03:29.300Z","avatar_url":"https://github.com/soarez.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Intro\n\n##### Problems\n\n- **Traveling back in time**\n\t- Revert files back to a previous state\n\t- Revert the entire project back to a previous state\n\t- Compare changes over time\n\t- See who last modified something that might be causing a problem\n\t- Who introduced an issue and when\n- Sharing\n- Collaborating\n- Paralelizing your work\n\t- Solving multiple issues separately\n\t- Make a quick fix in the midst developing a feature\n\n### Version Control Systems (VCS)\n\n#### Frequently making a backup\n\n  - The caveman solution\n  - Muggles still use this use this everyday\n\t- Designers\n\t- Managers\n\t- Lawyers\n\t- Doctors\n\t- …\n\n- Good\n\t- Pretty straightforward\n- Bad\n\t- CHAOTIC\n\n##### Local VCS\n\n- rcs\n- Good:\n\t- ???\n- Bad:\n\t- Hard to manage over time\n\t- Hard to collaborate\n\t- Single point of failure\n\n##### Centralized VCS\n\n  - CVS, Subversion, Perforce\n  - Standard solution for many years and still used by many\n  - Good\n    - Easier to collaborate\n    - Not too hard to understand\n    - Easier to administer a CVCS than it is to deal with local databases on\n      every client\n  - Bad\n    - Single point of failure\n    - Hard to work without access to the server\n\n##### Distributed VCS\n\n  - Git, Mercurial, Bazaar\n  - Clients fully mirror the repository\n  - No single point of failure\n  - Best for collaboration - Multiple remotes\n\n##### Git\n\n - Designed for:\n \t- Speed\n\t - Simple Design\n \t- Non-linear development (thousands of parallel branches)\n \t- Fully distributed\n  \t- Scale - Able to handle large projects like the Linux kernel efficiently\n    (speed and data size)\n - Different\n  \t- While other VCSs represent commits as file based changes, git takes\n    snapshots of the files.\n    Snapshots, not differences\n  \t- Git stores data as snapshots of the project over time\n  \t- Nearly every operation is local\n\t- Local history\n\t- Database is replicated when cloning\n  \t- You can commit without network connection\n\t- Integrity is built-in\n\nO rly? Who is using dat?\n\n- Linux\n- Rails\n- Google\n- Facebook\n- Microsoft\n- Twitter\n- LinkedIn\n- …\n\n**If you don't use Git, you better have a damn good reason not to.**\n\n\n###### Why you should NOT use a GUI for Git\n\n1. **Git is NOT famous for its interface**\n2. It is really HARD to change #1. It is a very likely unreliable abstraction.\n3. You're a programmer, not a manager or tech dude\n4. GUIs are slow\n\n\n# Setting up\n\n##### Configuration\n\n  - `/etc/gitconfig` - system\n  - `~/.gitconfig`   - global\n  - `.git/config`\n\nWindows: `C:\\Documents and Settings\\$USER\\.gitconfig`\n\n##### Identity\n\n    git config --global user.name \"John Doe\"\n    git config --global user.email johndoe@example.com\n\n##### Editor\n\n    git config --global core.editor vim\n\n##### Merge tool -- don't change this if you're not sure\n\n    gif config --global merge.tool vimdiff\n\n##### Check current settings\n\n    git config --list # show all config values, last ones have priority\n    git config user.name # show config value\n\n# Help\n\n    git help \u003cverb\u003e\n    git \u003cverb\u003e --help\n    man git-\u003cverb\u003e\n\nExample:\n\n    git help config\n\nIRC - irc.freenode.net\n\n  - \\#git\n  - \\#github\n\nFree book\n\n  - ProGit\n  \n# Git Basics\n\n### The 3 states for **tracked files**\n\n  - Commited\n    The data is safely stored in the database.\n  - Modified\n    Changed, but not commited.\n  - Staged\n    Marked modified file in its current version to go into the next commit\n\n### The 3 sections\n\n  - Git directory\n    Where Git stores the metadata and object database. This is what is copied\n    when a project is cloned\n  - Working directory\n    A single checkout of one version of the project, pulled from the database\n    to use or modify.\n  - Staging area - aka index\n    A file contained in the Git directory that stores information about the\n    next commit\n\n##### Initializing a repository in an existing directory\n\n    git init\n\n##### Cloning an existing repository\n\n    git clone \u003crepo\u003e\n\n##### Checking the status of your files\n\n    git status\n\n##### Start tracking new files or staging modified files\n\n    git add \u003cfilename\u003e\n    \n    # interactive\n    git add -i \u003cfilename\u003e\n\nA file is staged in its current version. If you make changes to a file after\nyou staging it, the new changes will not go into the new commit unless you\nstage the file again before commiting.\n\n##### Ignoring files\n\n    $EDITOR .gitignore\n\n##### See what is changed\n\n    git diff\n\n##### See what is staged\n\n    git diff --cached\n\n##### Commit!\n\n    git commit\n    git commit -m 'Add speech module #432'\n\n    # Thor-style commits\n    git commit -a -m 'fix stuff'\n    \nPreferably, commit messages:\n\n- Are in the present tense\n- Start with a capitalized letter\n- Have a subject that does not exceed 50 chars\n- Have a thourough message body that explains in detail what was changed and why. This message is linewrapped at 72 chars.\n\n##### Change last commit message\n\n    git commit --amend\n\n##### Remove files\n\n    git rm \u003cfilename\u003e\n    git rm \u003cfilename\u003e --cached\n\n##### Git accepts file-glob patterns\n\n    git add test/\\*.js\n    \nBecause bash does its own globbing, `*` is escaped.\n\n##### Moving files\n\n    mv \u003cold\u003e \u003cnew\u003e\n    git rm \u003cold\u003e\n    git add \u003cnew\u003e\n\n    # or\n\n    git mv \u003cold\u003e \u003cnew\u003e\n\n##### View the commit history\n\n    git log\n\n##### Removing file form staging area\n\n    git reset \u003cfilename\u003e\n\n##### Undo file changes\n\n    git checkout \u003cfilename\u003e\n\n##### Tagging\n\n    git tag \u003ctagname\u003e     # simple\n    git tag -a \u003ctagname\u003e  # annotated\n\n# Remotes\n\n##### List remotes\n\n    git remote -v\n\n##### Add a remote\n\n    git remote add \u003cname\u003e \u003curl\u003e\n\n##### Fetch remote database\n\n    git fetch \u003cremote\u003e\n\nDoes not change any of your own branches nor your working copy.\n\n##### Fetch + merge with current branch\n\n    git pull \u003cremote\u003e master\n\n##### Pushing\n\n    git push \u003cremote\u003e master\n\n# Branching\n\nBranching means diverging the from the current line of development.\n\nTo understand branching, you need to understand how commits are stored. A commit consists of:\n\n- message\n- author\n- commiter\n- date\n- pointer to a tree (snapshot), identified by its checksum\n- pointer to previous commits\n\nWhat are branches:\n\n- A branch in Git is simply a lightweight movable pointer to one of these commits. \n- When you commit, the branch moves forward, pointing to the new commit.\n- A branch in Git is in actuality a simple file that contains the 40 character SHA–1 checksum of the commit it points to\n\nTake note:\n\n- **Branching is inexpensive.**\n\t- Creating a new branch is just creating another pointer!\n\t- Creating a new branch is as quick and simple as writing 41 bytes to a file (40 characters and a newline).\n\t- Branching is a LOCAL operation, no server communication is needed\n- Switching branches changes the files in the working directory\n- A special pointer called `HEAD` always points to the current branch. \n\n##### Create a branch\n\n    git branch \u003cbranch_name\u003e\n\n##### Move to another branch\n\n    git checkout \u003cbranch_name\u003e\n\n##### Create a branch, and switch to it\n\n    git checkout -b \u003cbranch_name\u003e\n\n##### List branches\n\n    git branch\n\nThe `*` charater prefixes the current branch (`HEAD`)\n\n##### See the last commit on each branch\n\n    git branch -v\n\n##### Delete a branch:\n\n    git branch -d \u003cbranch_name\u003e\n\n\n### Topic branches\n\nYou should branch everytime you do something new. Branch for:\n\n- Fixes\n- Features\n- Experiments\n\n### Long-running branches\n\n##### If for some reason you do not care about versions. \n\n- Keep master stable\n\n##### If you want to have releases with specific versions.\n\n- Develop on master\n- Branch to stable release versions\n- Fix bugs on release versions branches and merge onto master\n- Never merge master onto release version branches\n\nSee semver.\n\n##### Multi-branded products\n\n- Keep master stable\n- Have a branch for each brand\n- Merge features onto master, and only then, merge master onto the branded branches\n\n### Remote branches\n\nReferences to the state of branches on remote repositories. They're local branches (pointers, remember!) that you can't move (directly).\n\nForm: `\u003cremote\u003e/\u003cbranch\u003e`\n\n##### Push a branch\n\n    git push \u003cremote\u003e \u003cbranch\u003e\n    # or \n    git push \u003cremote\u003e \u003clocal_branch\u003e:\u003cremote_branch\u003e\n    \n##### Checkout a remote branch\n\n    git checkout -b serverfix origin/serverfix\n    \n##### Setup a pre-existing branch to track an existing server branch\n\n    git checkout \u003clocal_branch\u003e\n    git checkout --track \u003cremote\u003e/\u003cremote_branch\u003e\n\n##### Delete a remote branch\n\n    git push \u003cremote\u003e :\u003cremote_branch\u003e\n\n\n# Merging\n\n##### Merge `\u003cbranch\u003e` into HEAD\n\n    git merge \u003cbranch\u003e\n\n### Fast forward merges\n\nWhen the commit on the branch you’re on isn’t a direct ancestor of the branch you’re merging in, or, in other words, when you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together — this is called a “fast forward”.\n\n### Three-way (or n-way)\n\nOtherwise, Git does a simple three-way merge. Git identifies the common ancestor and uses as a base for the 3-way merge. A new snapshot is created that results from this three-way merge and automatically, a new commit is created that points to it.\n\n#### Merge conflicts\n\nA merge conflict can happen in three-way merges when the same part of a file is changed by both branches being merged. Git pauses the merge process until the conflics are resolved.\n\n##### See which files are *unmerged*\n\n    git status\n    \n##### Conflict example\n\n    \u003c\u003c\u003c\u003c\u003c\u003c\u003c HEAD:index.html\r    \u003cdiv id=\"container\"\u003eAwesome!\u003c/div\u003e\r    =======\r    \u003cdiv id=\"container\"\u003e\n\t\tWunderbar!\n    \u003c/div\u003e\r    \u003e\u003e\u003e\u003e\u003e\u003e\u003e my-other-branch:index.html\n\n**Remember:** `HEAD` is was what you had checked out when you ran your merge command\n\n##### Mark file as resolved\n\n    git add \u003cfilename\u003e\n    \n##### Use the configured graphical tool to resolve the issues\n    \n    git mergetool\n    \n##### Continue the merge after all conflicts have been resolved\n\n\tgit commit\n\nBy default, the commit on a merge will be `'Merge branch \u003cbranch\u003e'`\n\n##### See which branches haven't yet been merged\n\n    git branch --no-merged\n\n# Rebasing\n\nReapplying a diverging branch onto another.\n\n    git checkout \u003cdiverging_branch\u003e\n    git rebase master\n    \nAfter rebasing, a merge of *master* with *diverging_branch* will fast-forward master.\n\n\nHow it works: Git …\n\n1. finds the common ancestor of the two branches (base)\n2. gets the diff of each commit of the branch you’re on, from the base\n3. saves those diffs to temporary files\n4. resets the current branch to the same commit as the branch you are rebasing onto\n5. applies each change (diff) in turn\n\n\u003e Rebasing replays changes from one line of work onto another in the order they were introduced, whereas merging takes the endpoints and merges them together.\n\n**The only difference between merging and rebasing is the resulting history.**\n\n#### Attention\n\n**!! Do not rebase pushed commits !!**\n\n# Distributed workflows\n\n### Centralized workflow\n\n- Everyone can commit\n- The first to push feels less pain\n- The second developer must merge/rebase before pushing\n- Common in centralized version control systems (CVCS)\n- Very basic, very common\n\n### Integration manager workflow\n\n- 1 maintainer\n- Everyone pulls from the maintainer\n- Contributions are made through pull requests\n- Maintainer pulls contributions from the colaborators' repos and merges them\n\n### Dictator and Lieutenants workflow\n\n- Good for big projects\n- Dictator owns the main repo\n- Lieutenants are responsible for components of the whole solution\n- Lieutenants integrate contributions from contributors\n- Dictator integrate pulling from his trusted Lieutenants\n\n# Tips\n\nAuto complete\n\n    source ~/git-completion.bash\n\nColors!\n\n    git config --global color.ui true\n\nLog\n\n    git config --global alias.l log --color --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)\u003c%aN\u003e%Creset'\n\nStatus\n\n    git config --global alias.s status -s\n\nStage parts of a file\n\n    git add -i \u003cfilename\u003e\n\nAlso, **use bash alias'es.**\n\nUse a bash prompt that tells you which branch you're currently on.\n\n    # Append this to .bash_profile\n    export PS1=\"\\W\\$(git branch 2\u003e /dev/null | grep -e '\\* ' | sed 's/^..\\(.*\\)/[\\1]/')$ \"\n    \n# For another day\n\n- Cherry picking\n- Commit squashing\n- Changing history\n- bisect\n- Submodules\n- merge strategies\n- whitespace settings\n- gitattributes\n- hooks\n- \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoarez%2Fgit-talk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoarez%2Fgit-talk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoarez%2Fgit-talk/lists"}