{"id":19232012,"url":"https://github.com/josemarqmt/personal-git-wiki","last_synced_at":"2026-04-12T16:02:27.434Z","repository":{"id":258266542,"uuid":"859907486","full_name":"josemarqmt/personal-git-wiki","owner":"josemarqmt","description":":pencil: Personal Git Wiki, notes and main git commands sorted by their usefulness.","archived":false,"fork":false,"pushed_at":"2024-10-16T13:40:10.000Z","size":61,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-05T00:16:09.239Z","etag":null,"topics":["git","github"],"latest_commit_sha":null,"homepage":"","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/josemarqmt.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-19T13:40:35.000Z","updated_at":"2024-10-16T13:44:27.000Z","dependencies_parsed_at":"2024-10-18T07:46:54.626Z","dependency_job_id":"b9889a22-d822-474d-bf54-041c74a345de","html_url":"https://github.com/josemarqmt/personal-git-wiki","commit_stats":null,"previous_names":["josemarqmt/personal-git-wiki","josemarqmt/personal_git_wiki"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josemarqmt%2Fpersonal-git-wiki","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josemarqmt%2Fpersonal-git-wiki/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josemarqmt%2Fpersonal-git-wiki/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josemarqmt%2Fpersonal-git-wiki/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josemarqmt","download_url":"https://codeload.github.com/josemarqmt/personal-git-wiki/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240307306,"owners_count":19780797,"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","github"],"created_at":"2024-11-09T16:05:05.032Z","updated_at":"2025-10-25T21:40:02.629Z","avatar_url":"https://github.com/josemarqmt.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"#  \u003cimg src=\"https://static-00.iconduck.com/assets.00/git-icon-2048x2048-juzdf1l5.png\" alt=\"git_icon\" style=\"width:50px;\"/\u003e Personal Git Wiki (commands and notes for personal use)\n\n1. [Git Fundamentals](#id1)\n2. [Git Commands](#id2)\u003cbr\u003e\n2.1 [Git Config - Get and set repository or global options](#id2.1)\u003cbr\u003e\n2.2 [Git Essential Commands](#id2.2)\u003cbr\u003e\n2.3 [Git Repository Management](#id2.3)\u003cbr\u003e\n2.4 [Git File Management](#id2.4)\u003cbr\u003e\n2.5 [Git Commit Management](#id2.5)\u003cbr\u003e\n2.6 [Git Branch Management](#id2.6)\u003cbr\u003e\n2.7 [Git Remote Repository Management](#id2.7)\u003cbr\u003e\n2.8 [Git Alias Commands](#id2.8)\u003cbr\u003e\n2.9 [Git Temporary Storage](#id2.9)\u003cbr\u003e\n2.10 [Git Transfer Commits Between Branches](#id2.10)\u003cbr\u003e\n\n\n\u003ca name=\"id1\"\u003e \u003c/a\u003e\n## 1. Git Fundamentals\n\n### Main or Master\nWhen you create a git repository, the default brands are Main or Master, often the main ones.\n\n### Git states\n  - Modified: \n    The file has changed but there is no confirmation to send.\n  - Staged:\n    The file is modified and marked as ready.\n  - Committed:\n    The file is saved in the repository.\n\n### Head\nThe pointer that references the current point in the commit history\n\n### .gitignore\nThe file indicates that Git should ignore certain file names from being tracked in the repository. \u003cbr\u003e \nAlso is possible to create a .gitignore global file in the home user directory  -\u003e \"~/.gitignore_global and write\" -\u003e \"git config --global core.excludesfile\" ~/.gitignore_global in the terminal\n\u003e Files that should be ignored\n\u003e\n\u003e Credentials or .env files\n\u003e\n\u003e ide configuration files\n\u003e\n\u003e systems files like .DS_Store\n\u003e\n\u003e log files\n\u003e\n\u003e Static or build files like /dist or /build directory\n\n\u003ca name=\"id2\"\u003e \u003c/a\u003e\n## 2. Git Commands\n\n\u003ca name=\"id2.1\"\u003e \u003c/a\u003e\n### 2.1 Git Config - Get and set repository or global options\n\u003e add --system, --global or local to a git config command to specify where the configuration will be established\n\u003e \n\u003e --system -\u003e The configuration will be applied for the entire systems and repository including all the users\n\u003e \n\u003e --global -\u003e The configuration will be applied for the current user\"\n\u003e \n\u003e --local -\u003e The configuration will be applied for the current repository\"\n- Show current git configuration, add --system, --global or --local to filter the configuration you want to see\n```\ngit config --list\n```\n- Associate username and email to commits in your device\n```\ngit config  user.name \"\u003cyour name\u003e\"\ngit config  user.email \"\u003cyour email\u003e\"\n```\n- Set git default editor\n```\ngit config --global core.editor \"editor name\"\n```\n- Use fast forward merge whenever possible\n```\ngit config --global merge.ff only\n```\n\n\u003ca name=\"id2.2\"\u003e \u003c/a\u003e\n### 2.2 Git Essential Commands\n- Show installed git version\n```\ngit version\n```\n- Show a command description\n```\ngit \u003cverb\u003e --help\n```\n\n\u003ca name=\"id2.3\"\u003e \u003c/a\u003e\n### 2.3 Git Repository Management\n- Initialize a new repository in the folder located\n```\ngit init\n```\n- Show repository status\n```\ngit status\ngit status -s # Shows the output of the command in a simplified form.\n```\n\n\u003ca name=\"id2.4\"\u003e \u003c/a\u003e\n### 2.4 Git File Management\n- Track a file and add it to the staging area\n```\ngit add \u003cfile\u003e\ngit add -A #add all the files that have been modified in the repository to the staging area\n```\n- Stop file tracking and remove it from the staging area\n```\ngit reset \u003cfile\u003e\n```\n- Undo a modified file\n```\ngit restore \u003cfile\u003e\ngit checkout -- \u003cfile\u003e\n```\n- Delete all new untracked files (not added to the staging area)\n```\ngit clean -n # shows which files will be deleted\ngit clean -f # delete the files\n```\n- Delete a file from the repository but keep it in your file directory\n```\ngit rm --cached \u003cfile\u003e\n```\n\n\u003ca name=\"id2.5\"\u003e \u003c/a\u003e\n### 2.5 Git Commit Management\n- Create commits in the repository history with the current state of the files added to the staging area\n```\ngit commit # This will open the previously configured editor to add the message\ngit commit -m \"title\" -m \"description\" # Write the commit title and description directly using the terminal\n```\n\n- Add the files to the staging area and commit simultaneously\n```\ngit commit -a -m 'message'\n```\n\n- Move HEAD to a previous commit\n```\ngit reset --soft HEAD~1 # The files committed in the last commit will be moved to the staging area\ngit reset HEAD~1 # The files committed will remain but as unstaged\ngit reset --hard HEAD~1 # The files committed will lose any changes made and new files will be removed\n```\n\n- Add new changes and/or change the message of the last commit\n```\ngit commit --amend -m \"message\"\n```\n\n\u003ca name=\"id2.6\"\u003e \u003c/a\u003e\n### 2.6 Git Branch Management\n- Create a new branch in the repository based on the current commit of the branch you're on\n```\ngit branch \u003cbranch\u003e\n```\n- Switch to an existing branch\n```\ngit switch \u003cbranch\u003e\n```\n- Create a new branch and switch to it directly\n```\ngit switch -c \u003cbranch\u003e\n```\n- Show a list of available branches locally\n```\ngit branch\n\n# Return the list sorted by creation date\ngit branch --sort=-committerdate #DESC\ngit branch --sort=committerdate  #ASC\n```\n\n- Merges changes made in another branch into the current branch\n\u003e git merge uses fast-forward or no fast-forward depending on the state of the branches being merged, but you can choose the merge method using --ff-only, --no-ff, --squash, --no-commit commands\n\u003e\n\u003e --ff-only -\u003e Used for merge changes of a branch is ahead of the current branch \"The branch ahead must share the previous commits that the current branch has in the same order\"\n\u003e \n\u003e --no-ff -\u003e Used for merging two brands that have diverged, git creates a new commit copying the changes of the branch to be merged into the current branch\n\u003e \n\u003e --squash -\u003e add the changes of the branch to be merged into the staging area instead of automatically committing them \"The parent commits are not referenced in the new commit and the history of the feature branch is lost in the main branch’s log\"\n\u003e\n\u003e --no-commit -\u003e same as --squash but the history of both branches is preserved, performing a regular merge\n```\ngit merge \u003cbranch\u003e\n\ngit merge --ff-only \u003cbranch\u003e # fast forward merge\n\ngit merge \u003cbranch\u003e --no-ff # no fast forward merge\n\ngit merge --squash # no automatically commit merge\n\ngit merge --no-commit # no automatically commit regular merge\n```\n- Re-committing all commits of the current branch onto a different base commit\n\u003e Use rebase to add changes from a base branch to a branched-out branch and to not create so many merge commits\n\u003e Never should be used to add changes to a base branch because you will modify the commit history\n```\ngit rebase \u003cbranch\u003e\n```\n- Delete a branch\n```\ngit branch -d # only will delete the branch if the branch is merged\n\ngit branch -D # delete the branch regardless of whether it is being merged or not\n```\n- Prune the local repository of branches pushed to the remote\n```\ngit remote prune \u003corigin\u003e --dry-run # return a list of branches that will be deleted if the command is used\ngit remote prune \u003corigin\u003e # delete unnecessary branches\n```\n\n\u003ca name=\"id2.7\"\u003e \u003c/a\u003e\n### 2.7 Git Remote Repository Management\n- Clone a remote repository and bring it locally\n```\ngit clone \u003cssh URL\u003e\n```\n- Show a list of remote repositories that are linked to the local repository\n```\ngit remote -v\n```\n- Config git the merge method used when pulling from a repository\n```\ngit config pull.rebase false # use the merge method when fast-forward is not available\n\ngit config pull.rebase true # use the rebase method when fast-forward is not available\n\ngit config pull.ff only # only accept fast-forward method\n```\n- Pull changes from a remote repository \n```\ngit pull \u003cremote\u003e \u003cbranch\u003e\n```\n- Push changes to a remote repository\n```\ngit push \u003cremote\u003e \u003cbranch\u003e\ngit push \u003cremote\u003e \u003cbranch\u003e -f # force and avoid error message\n```\n\n\u003ca name=\"id2.8\"\u003e \u003c/a\u003e\n### 2.8 Git Alias Commands\n- Create an alias\n```\ngit config --global alias.\u003calias name\u003e \u003c\"command\"\u003e\n```\n- Show a list of configured alias\n```\ngit config --get-regexp alias\n```\n\n\u003ca name=\"id2.9\"\u003e \u003c/a\u003e\n### 2.9 Git Temporary Storage\n\u003e It can be useful to move between branches without having to commit what you have modified\n- Save modified files in a temporary storage called stash\n```\ngit stash -m \u003cdescription\u003e# save track files\n\ngit stash -u -m \u003cdescription\u003e# save track and untracked files\n```\n- Show a list of saved stashes\n```\ngit stash list\n```\n- Apply the last temporary stash and remove it from the stack\n```\ngit stash pop\n```\n- Apply the stash according to an index keeping it in the stack\n```\ngit stash apply \u003cindex\u003e\n```\n- Remove a stash according to an index from the stack\n```\ngit stash drop \u003cindex\u003e\n```\n- Remove all stashes from the stack\n```\ngit stash clear\n```\n\n\u003ca name=\"id2.10\"\u003e \u003c/a\u003e\n### 2.10 Git Transfer Commits Between Branches\n- Apply the commit using its sha reference\n```\ngit cherry-pick \u003ccommit-sha\u003e\ngit cherry-pick \u003ccommit-sha\u003e -e # edit commit message\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosemarqmt%2Fpersonal-git-wiki","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosemarqmt%2Fpersonal-git-wiki","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosemarqmt%2Fpersonal-git-wiki/lists"}