{"id":16082273,"url":"https://github.com/alisson-ribeiro/git","last_synced_at":"2026-03-18T17:51:14.026Z","repository":{"id":231346762,"uuid":"770660555","full_name":"Alisson-Ribeiro/Git","owner":"Alisson-Ribeiro","description":"Git commands with description for later research","archived":false,"fork":false,"pushed_at":"2024-07-01T19:33:56.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T23:51:14.955Z","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/Alisson-Ribeiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2024-03-11T23:44:08.000Z","updated_at":"2024-07-01T19:33:59.000Z","dependencies_parsed_at":"2024-10-31T04:34:18.107Z","dependency_job_id":null,"html_url":"https://github.com/Alisson-Ribeiro/Git","commit_stats":null,"previous_names":["alisson-ribeiro/git"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alisson-Ribeiro%2FGit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alisson-Ribeiro%2FGit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alisson-Ribeiro%2FGit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alisson-Ribeiro%2FGit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alisson-Ribeiro","download_url":"https://codeload.github.com/Alisson-Ribeiro/Git/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247335689,"owners_count":20922487,"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-10-09T11:43:54.409Z","updated_at":"2026-03-18T17:51:14.000Z","avatar_url":"https://github.com/Alisson-Ribeiro.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git commands with description for later reference\n### Research purposes only\n\nEvery git command (or most of them) have arguments which add many possibilities and features to the given command, in this repository you will find the most usual ones. For the Official documentation refer to: [https://git-scm.com/docs]\n\n## A standalone individual developer does not exchange patches with other people, and works alone in a single repository, using the following commands:\n(obs: some of these commands will not have a description in this repository)\n\n* git init\n* git log\n* git clone\n* git config\n* git alias\n* git reset\n* git revert\n* git checkout\n* git switch\n* git branch\n* git add\n* git diff\n* git status\n* git commit\n* git restore\n* git merge\n* git rebase\n* git tag\n\n## Main branches commands\n### Efficient use of branches is crucial for collaborative and organized development.\n\n* git branch 'branch-name' ---\u003e creates a new branch with the specified name\n\n* git checkout 'branch-name' ---\u003e switches to the specified existent branch\n\n* git checkout -b 'branch-name' ---\u003e creates and switches to the specified branch in a single command\n\n* git checkout 'commit-hash' ---\u003e travels along the development timeline to the specified commit\n\n* git branch ---\u003e lists every existent branches in repository\n\n* git branch -d 'branch-name' ---\u003e deletes a branch\n\n* git branch -D 'branch-name' ---\u003e forces deletion of a branch which has unmerged changes (it's strongly recommended to avoid deleting branches with unmerged changes as this can disrupt your Git history and make it difficult to recover lost work)\n\n* git push origin -d 'branch-name' ---\u003e  If you want to delete a remote branch, you'll need to push the deletion to the remote repository\n\n* git push 'remote' :'branch-name' ---\u003e deletes the remote branch\n\n* git branch -m 'new-branch-name' ---\u003e renames a local branch\n\n* git push 'remote' branch-name ---\u003e sends a new branch to remote repository\n\n* git push 'remote' --force ---\u003e the usage of '--force' option replaces the contents of the remote branch with the contents of the local branch, even if this results in the loss of commits or history in remote repository\n\n* git fetch 'remote' 'branch-name' ---\u003e brings (download) a remote branch to your local repository\n\n* git merge 'branch-name'---\u003e merges a branch into your current branch, creates a merge commit and keeps the whole commit history from both branches. If you use the command 'git log', you will be able to see every commit from both branches now in a single branch. The 'git merge' command doesn't delete the merged branch, you can still checkout to the merged branch and keep working and committing to the branch, if you do so, these commits are not added automatically, so you'll need to 'git merge' again. Git merge is often more used for shared branch work where more people are working together instead of 'git rebase' due to maintaining commit history regardless of project complexity\n\n* git branch -v ---\u003e lists the existent branches in repository, along with last commit info of each branch\n\n* git branch -r ---\u003e lists all the remote branches in git repository. This command is helpful when you want to see the available branches on the remote repository without fetching them.\n\n## Switch\n### Introduced in version 2.23, we have the git switch command, which we can use to switch between branches. Ok, and what about the 'git checkout' command?\n\n### The 'git checkout' command is a versatile one, it can (among other things) restore especific files or even commits, while the new 'git switch' command is used only to switch between branches. futhermore, the 'git switch' command checks for additional consistencies that 'git checkout' doesn't, for example the 'git switch' would abort the operation if it would lead to loss of local changes.\n\n* git switch 'branch-name' ---\u003e switches to the specified branch-name\n\n* git switch - ---\u003e switches back to previous branch, similar to 'cd -'\n\n* git switch --create 'branch-name' ---\u003e creates and switches to the name-specified branch\n\n## Restore\n### Introduced in version 2.23, 'git restore' we can use to restore a file to the last committed version of it.\n\n* git restore --staged file.py ---\u003e Undo changes made to a file, equivalent to 'git reset file.py'\n\n## Diff\n### Shows changes between commits, branches, files and others\n\n* git diff ---\u003e shows the changes made (and were not commited) since the last commit by default\n\n* git diff branch1 branch2 ---\u003e shows a comparison between the 2 specified branches\n\n* git diff 'commit-hash' 'commit-hash' ---\u003e shows the difference between the 2 specified hash commits\n\n* git diff --color-words ---\u003e highlight the changes made with red (deletion), green (insertion) and white (not touched by any change)\n\n## Tag\n### A known checkpoint for your project\n\n* git tag ---\u003e lists the existent tags\n\n* git tag -A 'tag' -m \"message\" ---\u003e creates a tag with a message, 'tag' generally is like a release format 'v1.0'\n\n* git tag -d v1.0 ---\u003e deletes the specified tag\n\n### Sharing of tags is similar to branches. By default, 'git push' does not send tags to remote. Tags demand a explicit 'git push' ---\u003e example: 'git push origin v1.0'\n\n## Stash\n### Store your code for later use (it's not a commit). Archives (or stashes) changes you made to the working copy, so you can work anywhere else, and then return to the stashed point.\n### Hint: never commit a not working patch! Stash it instead!\n### Attention: 'git stash' command does not stashes changes made to untracked and ignored files.\n\n* git stash ---\u003e stashes changes for later use\n### Obs: Stashes are local to your repository, stashes are not sent to remote when pushing (git push)\n### Obs¹: It does not include untracked and ignored files\n\n* git stash pop ---\u003e brings out of the stash and apllies to the working copy, removing from stash\n### Obs: Brings out of the stash the most recent by default\n### Obs¹: You can choose which stash to bring by informing its id as last argument ---\u003e example: 'git stash pop stash@{2}'\n\n* git stash apply ---\u003e brings out of the stash and apllies to the working copy, keeping the copy in stash... it's useful if you may apply the same stash to more branches\n\n* git stash -u (or --include-untracked) ---\u003e stashes changes for later use, including untracked files but not the ignored ones\n\n* git stash -a (or --all) ---\u003e stashes changes for later use, includes untracked and ignored files\n\n* git stash save \"message\" ---\u003e adds a message to your stash, useful when more stashes are created so you don't get lost\n\n* git stash show ---\u003e shows a summary, or you can add as an option -p (or --patch) to visualize the full stash comparison\n\n* git stash drop stash@{n} ---\u003e deletes the stash informed in brackets, for a single drop\n\n* git stash clear ---\u003e to delete all stashes\n\n## Alias\n### Alias is not a command in git, but a tool you can configure to obtain efficiency and productivity. Aliases are created using the 'git config' command. See these examples:\n\n* git config --global alias.co ---\u003e checkout\n\n* git config --global alias.br ---\u003e branch\n\n* git config --global alias.st ---\u003e status\n\n### It creates shortcuts with global storage for the given command\n\n## Log\n### See what and where is anything in your project. The 'git log' and its variations add so many visualizations for you to handle the info you need.\n\n* git log ---\u003e shows every commit in current branch (no filter)\n\n* git log --oneline ---\u003e a summary of git log\n\n### The 'git log' command includes many options to show comparisons with each commit. The most commom ones are: '--stat' and '-p'.\n\n### The '--stat' option shows the number of insertions e deletions for each changed file by each commit. It's useful for a brief summary of changes made by each commit. For example: the following commit added 67 lines to the file 'file.py' and removed 38 lines.\n\n### If you want to see the changes introduced by each commit, you can use the option '-p' in 'git log'. Howerver, for commits with many changes, the output can be long and hard to handle\n\n* git shortlog ---\u003e is a special version of 'git log', groups each commit by author and shows the first line of each commit message. It's a easy way to see where someone is working at.\n\n* git log --graph ---\u003e draws a ASCII graphic representing the branch structure of the commit history, it's usually used with '--oneline' and '--decorate' options. It's a good tool for simple repository with few branches, but for larger projects with many branches you'd rather use a tool called 'Sourcetree'. Link: [https://www.atlassian.com/br/software/sourcetree]\n\n* git log -n ---\u003e filter and shows only the n last commits\n\n* git log --after=\"2024-1-1\" ---\u003e filter and shows only the commits created after the specified date. Also works with '--before=\"2024-1-1\"'\n\n* git log --after=\"2024-1-1\" --before=\"2024-1-2\" ---\u003e filters and shows the commits created between the specified dates\n\n* git log --author=\"Jose\" ---\u003e filters and shows commits created by a specific user. You can also add arguments to the filter, for example: '--author=\"jose\\\\|Maria\"' ---\u003e this will return commits created by Jose or Maria\n\n* git log -S\"Hello, World!\" ---\u003e filters and shows commits that introduced a specific line\n\n* git log main..feature ---\u003e shows the commits present in feature branch, but not in main branch. It's the progress the feature branch has achieved since it was separated from main\n\n## Collaborative workflows\n### How to sincronize (git remote) || the 'git remote' command is an interface to manage a list of remote entries to the repository\n\n### How to view git remote settings\n\n* git remote ---\u003e lists the remote connections you have with other repos\n\n* git remote -v ---\u003e lists the remote connection with other repos with the URL included for each connection\n\n### Shows where you are (fetch)ing from and where you (push)ing to\n\n### How to inspect a remote\n\n* git remote show 'remote-connection' ---\u003e gives a detailed output about the remote settings. This output contains a list of related branches to remote and also to the attached terminals to fetch and push\n\n### Setting up a new remote repository\n\n* git remote add 'repository-url'\n\n### How to send to remote\n\n* git push 'remote-name' 'branch-name' ---\u003e sends a local state to the specified remote\n\n### Renaming and removing remotes (self-explanatory)\n\n* git remote rename 'old-name' 'new-name'\n\n* git remote rm 'remote-name'\n\n## Pull\n### The 'git pull' command is used to fetch and download content from remote repositories and immediately update the local repo so the contents are the same. The command is a combination of other two commands: 'git fetch' and 'git merge'.\n### The command 'git fetch' may be taken as the same to 'git pull'. Both are used to download remote data. But there are important security issues between them. The 'git fetch' is the safest option, while 'git pull' is less secure. The 'git fetch' downloads the remote data and does not alter the state of the local repo. The 'git pull' downloads remote data and immediately merges to the local repo, what may lead to conflicts.\n\n* git pull origin main ---\u003e by default fetches, merges then creates a local commit with the content of divergent remote commits\n\n### The 'git pull' comand can also receive the option '--rebase', it copies the divergent remote commits and rewrites the local ones to appear after in the commit historic instead of creating a merge commit.\n\n* git pull --rebase ---\u003e (explanation above)\n\n### In fact, 'git pull --rebase' is a most commom used option that there's an option dedicated to set it up\n\n* git config --global branch.autosetuprebase always ---\u003e after executing this command, every 'git pull' will be integrated by 'git rebase' instead of 'git merge'\n\n## Push\n\n* git push 'remote' 'branch' ---\u003e\n\n* git push 'remote' --force ---\u003e\n\n* git push 'remote' --tags ---\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisson-ribeiro%2Fgit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falisson-ribeiro%2Fgit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisson-ribeiro%2Fgit/lists"}