{"id":13643270,"url":"https://github.com/cheatsnake/quick-git","last_synced_at":"2026-01-21T21:46:50.445Z","repository":{"id":186751899,"uuid":"675271151","full_name":"cheatsnake/quick-git","owner":"cheatsnake","description":"A quick overview of the main commands for working with the Git.","archived":false,"fork":false,"pushed_at":"2023-08-07T13:57:08.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-09T15:42:24.527Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheatsnake.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}},"created_at":"2023-08-06T11:17:36.000Z","updated_at":"2023-08-07T13:56:15.000Z","dependencies_parsed_at":"2024-01-14T12:18:13.333Z","dependency_job_id":null,"html_url":"https://github.com/cheatsnake/quick-git","commit_stats":null,"previous_names":["cheatsnake/quick-git"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheatsnake%2Fquick-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheatsnake%2Fquick-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheatsnake%2Fquick-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheatsnake%2Fquick-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheatsnake","download_url":"https://codeload.github.com/cheatsnake/quick-git/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249982590,"owners_count":21355727,"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-08-02T01:01:44.978Z","updated_at":"2026-01-21T21:46:50.435Z","avatar_url":"https://github.com/cheatsnake.png","language":null,"readme":"# Quick Git\n\n[`English`](./README.md) [`Русский`](./README_RUS.md)\n\nA quick overview of the main commands for working with the Git version control system.\n\n## Content\n\n-   [Basic commands](#basic-commands)\n-   [Information about commits](#information-about-commits)\n-   [Working with branches](#working-with-branches)\n-   [Remote repositories](#remote-repositories)\n-   [Deferred (hidden) commits](#deferred-hidden-commits)\n-   [Commit deletions and rollbacks](#commit-deletions-and-rollbacks)\n-   [Additional and similar resources](#additional-and-similar-resources)\n\n## Basic commands\n\nA **repository** is a place where the source code and change history of your project is stored. A repository can be local (on your computer) or remote (on a server).\n\n```shell\ngit init # Initializing a new repository\n```\n\n```shell\ngit status # Show the status of files in the current repository\n```\n\n-   **Untracked files** - Git doesn't know these files exist, so it has no effect on them.\n-   **Modified files** - these files were previously added for tracking and now Git has detected that their contents have changed since the last commit.\n-   **Files in Index (Staged)** is the intermediate state of files that were previously Untracked or Modified and are now pre-committed and ready to be included in a new commit.\n\n```shell\ngit add . # Add all Untracked and Modified files in Index\ngit add file.name # Add only a specific file\ngit add ./**/*.js # Add all files with the .js extension\n```\n\n```shell\ngit rm file.name # Remove the added file from Index\ngit reset file.name # Similar to the command above\n```\n\n**Commit** is a record in the repository history that represents information about changes to files. Each commit has a unique identifier (hash) and some metadata.\n\n```shell\ngit commit -m \"comment\" # Create a new commit with the specified message\ngit commit --amend -m \"Updated message\" # Overwrite the message for the last commit\ngit commit --amend --no-edit # Add changes to the last commit\n```\n\n```shell\ngit tag \u003ctag_name\u003e \u003ccommit_hash\u003e # Add a tag (alias) for the commit.\n# This tag can now be used instead of a hash to refer to a specific commit.\ngit tag # Display a list of available tags\n```\n\n```shell\ngit mv \u003cpath/to/file\u003e \u003cnew/path/to/file\u003e # Moving a file (a special case of renaming)\n```\n\n```shell\ngit restore file.name # Canceling changes to a file that has not yet been committed\ngit checkout file.name # Similar to the command above (obsolete approach)\n```\n\n## Information about commits\n\n```shell\ngit log # Display commit history\ngit log -3 # Output the last 3 commits\ngit log --oneline # History output in one line for each commit\ngit reflog # Information about commits and actions performed (stored locally for you only)\n```\n\n```shell\ngit show \u003ccommit_hash\u003e # Show commit information\ngit diff \u003ccommit_hash\u003e # Show the difference between the selected commit and the current state\ngit diff \u003ccommit_hash\u003e \u003ccommit_hash\u003e # Show the difference between two commits\ngit diff \u003cfile_name\u003e # Show changes to the selected file\n```\n\n## Working with branches\n\n**Branch** - a sequence of commits. As a rule, there is one main branch (Master/Main branch) in a repository. From this branch (from any of its commits) you can start new independent branches, where you can develop some new functionality, adding more and more new commits.\n\n```shell\ngit branch # Display a list of available branches and the current branch\ngit checkout -b \u003cbranch_name\u003e # Create a new branch from the current one and go directly to it\ngit checkout - # Quickly switch to the previous branch\ngit branch \u003cbranch_name\u003e # Switch to another branch\ngit branch \u003cnew_branch_name\u003e \u003ccommit_hash\u003e # Create a branch from a specific commit\n```\n\n**Merge** - the process of joining changes from one branch into another.\n\n```bash\ngit merge \u003cbranch_name\u003e # Merge the current branch with the specified branch (with all its commits)\ngit merge --squash \u003cbranch_name\u003e # Similar to the command above, only all commits will be merged into one final one\ngit cherry-pick \u003ccommit_hash\u003e # Merge the current branch with a commit from another branch\ngit rebase \u003cbranch_name\u003e # Update commit history and integrate changes from the specified branch\ngit branch -d \u003cbranch_name\u003e # Delete branch\n```\n\n**Merge conflict** - a merge situation where two branches have different changes in the same location and Git cannot automatically merge them.\n\n## Remote repositories\n\n```shell\ngit remote add origin \u003cURL\u003e # Connect to the remote repository and name it \"origin\"\ngit push --set-upstream origin \u003cbranch_name\u003e # Connect the branch to \"origin\" repo\ngit push # Send changes to a remote repository\ngit pull # Download changes from a remote repository and immediately merge to the local branch\ngit fetch # Only download changes from a remote repository without automatic merge\n# (this will allow you to view the code and decide for yourself how to merge it with local)\ngit push -u origin \u003cbranch_name\u003e # Send a new branch to a remote repository\ngit push --delete origin \u003cbranch_name\u003e # Remove a branch from a remote repository\ngit remote remove origin # Remove connection to remote \"origin\" repository\ngit remote -v # Show the list of connected remote repositories\n```\n\n## Deferred (hidden) commits\n\n**Git stash** allows you to temporarily save ongoing uncommitted changes in a special area called `stash`. This is useful when you want to switch to another task or branch, but don't want to commit incomplete changes. You can later apply the saved changes back to your working copy.\n\n```shell\ngit stash save \"message\" # Save the currently changes to stash with the specified message\ngit stash list # View a list of all saved stashes\ngit stash apply # Retrieve the last saved changes from stash, leaving a copy in stash\ngit stash apply \u003cstash_number\u003e # Retrieve saved changes from stash by its sequence number, leaving a copy in stash\ngit stash pop # Retrieve the last saved changes from stash and delete their copy from stash\ngit stash clear # Clear stash\n```\n\n## Commit deletions and rollbacks\n\n```bash\ngit reset \u003ccommit_hash\u003e # Delete all commit commits up to the specified commit\n# All changes from deleted commits can now be committed again\n# (e.g., to create a single shared commit)\ngit reset --hard # Delete all uncommitted changes and modifications added to the index but not yet committed\ngit revert \u003ccommit_hash\u003e # Create a new commit that undoes changes made to the specified commit\n# (a secure way to roll back changes while retaining all history)\n```\n\n## Additional and similar resources\n\n-   [**Learn Git concepts, not commands** - GitHub](https://github.com/UnseenWizzard/git_training)\n-   [**Understanding Git through images** - DEV Community](https://dev.to/nopenoshishi/understanding-git-through-images-4an1#adapt-to-remote)\n-   [**A curated list of Git tools, resources and shiny things** - GitHub](https://github.com/dictcp/awesome-git)\n","funding_links":[],"categories":["Software"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheatsnake%2Fquick-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheatsnake%2Fquick-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheatsnake%2Fquick-git/lists"}