{"id":20511439,"url":"https://github.com/friedrith/discover-git","last_synced_at":"2026-06-06T10:32:07.971Z","repository":{"id":72463716,"uuid":"219305986","full_name":"friedrith/discover-git","owner":"friedrith","description":"A tutorial to discover git","archived":false,"fork":false,"pushed_at":"2019-11-06T22:46:57.000Z","size":77,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-16T09:07:46.461Z","etag":null,"topics":["git"],"latest_commit_sha":null,"homepage":null,"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/friedrith.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":"2019-11-03T13:35:05.000Z","updated_at":"2019-11-06T22:46:59.000Z","dependencies_parsed_at":"2023-03-14T17:31:20.315Z","dependency_job_id":null,"html_url":"https://github.com/friedrith/discover-git","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/friedrith%2Fdiscover-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friedrith%2Fdiscover-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friedrith%2Fdiscover-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friedrith%2Fdiscover-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friedrith","download_url":"https://codeload.github.com/friedrith/discover-git/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242117658,"owners_count":20074433,"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"],"created_at":"2024-11-15T20:35:59.352Z","updated_at":"2025-03-05T22:42:59.677Z","avatar_url":"https://github.com/friedrith.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# discover-git\n\nA tutorial to discover git\n\n- [Introduction](Introduction)\n- [Architecture](Architecture)\n- [Installation](Installation)\n  - [Windows \u0026 macOS](windows--macos)\n  - [Linux](Linux)\n- [Getting started](Getting started)\n- [Commit](Commit)\n- [Remote](Remote)\n- [Branch](Branch)\n\n## Introduction\n\n[Git](https://git-scm.com/) is a versioning tool created by [Linus Torvals](https://fr.wikipedia.org/wiki/Linus_Torvalds) to manage development projects. With git, you can:\n\n- save remotely your work: you won't lose everything if your computer crashes\n- work on a project with others: you won't lose time to share your work depending on how many teammates you have\n- rollback whatever change you want: you won't fear to break your project\n- identify who wrote each line: you will be able to ask for help to the author\n\nGit is not the only tool to provide these features. Some other tools like [SVN](https://subversion.apache.org/) but git is the most popular and its strong architecture make it very relevant for collaboration.\n\nSo using git may need training but it worths it.\n\n## Architecture\n\nGit is a technology designed to be useful in peer-to-peer but main projects use it with\nan architecture client/server.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./assets/architecture.png\" alt=\"architecture git\" /\u003e\n\u003c/p\u003e\n\nWith git, a project is called a **repository**.\n\n## Installation\n\n### Windows \u0026 macOS\n\nDownload and install [git bash](https://git-scm.com/downloads).\n\n[Graphical client also exist.](https://git-scm.com/downloads/guis)\n\nThe most popular graphical clients are:\n\n- [Tortoise git](https://tortoisegit.org/)\n- [Github desktop](https://desktop.github.com/)\n- [Kraken](https://www.gitkraken.com/)\n\n### Linux\n\n```bash\n# on Ubuntu\napt-get install git\n```\n\n## Getting started\n\nDownload your repository using following command:\n\n```bash\ngit clone https://github.com/friedrith/hello-world-git.git\n```\n\n\u003e To follow this tutorial you need to be writing rights on the repository.\n\n## Commit\n\nIn git, the developer can gather a certain amount of code changes into a unitary block called **commit**. And so the history of the repository is a chain of **commits**.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./assets/commits.png\" alt=\"commits\" width=\"50%\" /\u003e\n\u003c/p\u003e\n\n### List commits\n\nYou can see the existent commits in a repository using following command:\n\n```bash\ngit log\n```\n\nThis command shows you the commits by reverse chronological order: from the latest one to the first one.\n\n```\ncommit c99fb1f8a03f8f53823da464b18aead3ccf9008e\nAuthor: Thibault Friedrich \u003cthibault.friedrich@gmail.com\u003e\nDate:   Sun Nov 3 09:40:37 2019 -0500\n\n    say hello in german\n\ncommit 7e7ed6683d81c4c76d28fab2724b227dead6fd1d\nAuthor: Thibault Friedrich \u003cthibault.friedrich@gmail.com\u003e\nDate:   Sun Nov 3 09:40:15 2019 -0500\n\n    say hello in french\n```\n\nYou can see that each commit is identified by a base64 number, an author, a date and a message.\n\n### Add your own commit\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./assets/commits_plus_one.png\" alt=\"add a commit\" width=\"65%\" /\u003e\n\u003c/p\u003e\n\nℹ️ Write what you want in file README.md in the repository then create your first commit:\n\n```bash\ngit commit -am \"\u003cyour own message\u003e\"\n```\n\n\u003e Using `git log`, you can see your own commit in the history\n\n### Add a commit with your own file\n\nYour first commit worked because the file was already tracked by git. If you add a new file, it won't be automatically committed by git.\n\nCreate your own file.\n\nℹ️ You can know the untracked files using command:\n\n```bash\ngit status\n```\n\n\u003e This command doesn't change the state of the repository so you can abuse of it without limitations.\n\nℹ️ Add your file to the git tracking:\n\n```bash\ngit add \u003cfile path\u003e\n```\n\nThen you will be able to commit it using `git commit`.\n\n\u003e Be careful to the files you track in your repository. Binary files (except small images), temporary files or build files should not be tracked since they can cause overweight or conflicts. You are incitated to create .gitignore file\n\n## Remote\n\nOnce you have saved your changes, you may want to sent it remotely to save permanently and share it.\n\n### Push\n\nIn git, the way to send your code is called **push**.\n\nℹ️ To push your code:\n\n```bash\ngit push\n\n```\n\n⚠️ When you work locally everything is easily canceable. It is far harder once you have pushed. So use `git push` with caution.\n\n### Pull\n\nYou will also need to get the code wrote by the other teammates\n\nℹ️ To pull your code:\n\n```bash\ngit pull --rebase # option rebase is not mandatory but strongly recommended\n\n```\n\n\u003e In theory, you could use only above commands to work as a team but other teammates wouldn't be able to see your code before they have it on their computer so it might be dangerous if it breaks their own code.\n\n## Branch\n\nWith previous commands, you have been able to save your changes (commit), send it online (push) and get other's work (pull). Now we will see how to navigate between your history, your work and work of other teammates using the recommanded methodologies.\n\n### Separate a side feature\n\nSometimes, you want to try something without messing your main code. To do that, git integrates a concept called **branch**. So that you can have several branches with a specific state of your code in each branch.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./assets/branch.png\" alt=\"add a commit\" width=\"65%\" /\u003e\n\u003c/p\u003e\n\nℹ️ Create your own branch\n\n```bash\ngit branch \u003cbranch name\u003e # branch name without spaces, we reommaend your to use only [a-zA-Z0-9_/] characters.\n```\n\nℹ️ See all the available branch\n\n```bash\ngit branch\n```\n\nℹ️ Switch to your new branch\n\n```bash\ngit checkout \u003cbranch name\u003e\n```\n\nOnce you have applied changes to your code and committed it in the branch, you can push your branch:\n\n```bash\ngit push origin \u003cbranch name\u003e\n```\n\n\u003e Sometimes it is useful to have local branches to test features. If so, you don't need to push the branch. You can juste merge into your main branch following commands below.\n\n### Merge branches\n\n#### Rebase\n\nThe **rebase** strategy is the more common way to merge branch since it is the way you should\nuse on your computer.\n\nApplied changes to your code on the branch \u003cbranch name\u003e and commit it then:\n\n```bash\ngit checkout master # yes master is branch\n```\n\nApplied changes\n\nℹ️ Rebase your code:\n\n```bash\ngit rebase \u003cbranch name\u003e\n```\n\n## Useful links\n\n- [Official documentation](https://git-scm.com/docs/git)\n- https://rogerdudler.github.io/git-guide/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriedrith%2Fdiscover-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriedrith%2Fdiscover-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriedrith%2Fdiscover-git/lists"}