{"id":18420488,"url":"https://github.com/ahmedgulabkhan/git-for-noobs","last_synced_at":"2025-04-13T09:18:25.145Z","repository":{"id":101005659,"uuid":"415244616","full_name":"ahmedgulabkhan/git-for-noobs","owner":"ahmedgulabkhan","description":"A complete beginner friendly guide to Git, it's concepts and some of the most widely used Git commands","archived":false,"fork":false,"pushed_at":"2021-12-16T17:36:57.000Z","size":43,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T09:18:19.842Z","etag":null,"topics":["dvcs","git","git-cheatsheet","git-commands","git-guide","vcs"],"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/ahmedgulabkhan.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":"2021-10-09T08:06:11.000Z","updated_at":"2024-09-29T22:21:30.000Z","dependencies_parsed_at":"2023-09-14T08:47:13.046Z","dependency_job_id":null,"html_url":"https://github.com/ahmedgulabkhan/git-for-noobs","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/ahmedgulabkhan%2Fgit-for-noobs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedgulabkhan%2Fgit-for-noobs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedgulabkhan%2Fgit-for-noobs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedgulabkhan%2Fgit-for-noobs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmedgulabkhan","download_url":"https://codeload.github.com/ahmedgulabkhan/git-for-noobs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688548,"owners_count":21145766,"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":["dvcs","git","git-cheatsheet","git-commands","git-guide","vcs"],"created_at":"2024-11-06T04:21:53.629Z","updated_at":"2025-04-13T09:18:25.125Z","avatar_url":"https://github.com/ahmedgulabkhan.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git for Noobs\n\n![Git for Noobs](./assets/git.jpg)\n\nThis documentation will help you get started with Git, it's terminology, and also contains the most \nwidely used git commands.\n\nThis documentation is open for contribution and for updating any mistakes.\n\n## Table of contents\n- [What is Git?](#what-is-git)\n- [Setting it up locally](#setting-it-up-locally)\n- [Configuring Git](#configuring-git)\n- [Concepts and terminology](#concepts-and-terminology)\n- [Most widely used commands along with their use cases](#most-widely-used-commands-along-with-their-use-cases)\n  - [git add](#git-add)\n  - [git apply](#git-apply)\n  - [git branch](#git-branch)\n  - [git checkout](#git-checkout)\n  - [git clone](#git-clone)\n  - [git commit](#git-commit)\n  - [git config](#git-config)\n  - [git describe](#git-describe)\n  - [git diff](#git-diff)\n  - [git fetch](#git-fetch)\n  - [git init](#git-init)\n  - [git log](#git-log)\n  - [git merge](#git-merge)\n  - [git mv](#git-mv)\n  - [git notes](#git-notes)\n  - [git pull](#git-pull)\n  - [git push](#git-push)\n  - [git rebase](#git-rebase)\n  - [git remote](#git-remote)\n  - [git replace](#git-replace)\n  - [git reset](#git-reset)\n  - [git restore](#git-restore)\n  - [git revert](#git-revert)\n  - [git rm](#git-rm)\n  - [git show](#git-show)\n  - [git stash](#git-stash)\n  - [git status](#git-status)\n  - [git switch](#git-switch)\n  - [git tag](#git-tag)\n- [Miscellaneous](#miscellaneous)\n- [References](#references)\n\n\n## What is Git?\nVersion control, also known as source control, is the practice of tracking and managing changes to \nsoftware code. Version control systems (VSCs) are software tools that help software teams manage changes to \nsource code over time. As development environments have accelerated, version control systems help \nsoftware teams work faster and smarter.\n\nGit is the most widely used modern version control system in the world today. Having a distributed \narchitecture, Git is an example of a DVCS (hence Distributed Version Control System). Rather than have \nonly one single place for the full version history of the software as is common in once-popular \nversion control systems like CVS or Subversion (also known as SVN), in Git, every developer's \nworking copy of the code is also a repository that can contain the full history of all changes.\n\n## Setting it up locally\n### Installation\n\nTo install Git on your local machine, visit [https://git-scm.com/downloads](https://git-scm.com/downloads). \nDepending on your operating system, download and install the latest version accordingly. During the \ninstallation process, make sure that you select thr option to add **git** to your path. This makes \nsure that the git commands are recognized from any location in the terminal.\n\n### Verify the installation\nOpen your terminal and type the command `git --version`, if you see the git version in the output, it \nmeans that the installation was successful.\n\n### Some useful options\nTo print the Git version that is currently installed:\n```\n$ git --version\n```\n\nTo print the synopsis, and a list of the most commonly used commands:\n```\n$ git --help\n```\n\nIf the option `--all` or `-a` is given then all the available commands are printed:\n```\n$ git --help --all\n```\n\nIf a Git command (`config` in this case) is mentioned along with `--help`, it brings up the manual \npage for that command in your browser:\n```\n$ git --help config\n```\n\n## Configuring Git\nGit uses a series of configuration files to determine non-default behavior that you may want. The \nfirst place Git looks for these values is in the system-wide `[path]/etc/gitconfig` file, which \ncontains settings that are applied to every user on the system and all of their repositories. \nIf you pass the option `--system` to git config, it reads and writes from this file specifically.\n\nThe next place Git looks is the `~/.gitconfig` (or `~/.config/git/config`) file, which is specific \nto each user of the system. You can make Git read and write to this file by passing the `--global` \noption.\n\nFinally, Git looks for configuration values in the configuration file in the Git directory \n(`.git/config`) of whatever repository you’re currently using. These values are specific to that \nsingle repository, and represent passing the `--local` option to git config. If you don’t specify which \nlevel you want to work with, this is the default.\n\nEach of these “levels” (system, global and local) overwrites values in the previous level, so values \nin `.git/config` (global config, which applies to a single user of the system) trump those in \n`[path]/etc/gitconfig` (system config, which applies to all users of the system), for instance.\n\n### Configuration levels\nIn order to specify the git configuration for all the users of the system, use:\n```\n$ git config --system\n```\n\nIn order to specify the git configuration for a specific user of the system, use:\n```\n$ git config --global\n```\n\nIn order to specify the git configuration for the current git project that you're using, use:\n```\n$ git config --local\n```\n\nIf no level is specified along with the `git config` command, then the default level is local. \nTherefore, using `git config --local` or `git config` would be the same.\n   \n### Setting the config properties\nBelow are a few example that show how a git property is set at any level.\nTo set the `user.name` property on the global level (inside `.git/config` file):\n```\n$ git config --global user.name={username}\n```\n\nTo set the `user.email` property on the system level (inside `[path]/etc/gitconfig` file):\n```\n$ git config --system user.email={useremail}\n```\n\n### Listing the config properties\nTo see all the properties configured globally in Git, you can use the `–-list` option on the git config \ncommand. Adding the `-–show-origin` option will also output the gitconfig file’s location (based on \nwhat level is selected - local, global or system).\n\nList all the properties present in the global gitconfig file and also output the location of the \nglobal gitconfig file on your machine:\n```\n$ git config --global --list --show-origin\n```\n   \n### Updating the config properties\nTo add a new proxy, without altering any of the existing ones:\n```\n$ git config --global --add core.gitproxy '\"proxy-command\" for example.com'\n```\n\nTo remove or unset a config property:\n```\n$ git config --global --unset core.editor\n```\n\nTo remove or unset all the values of a property:\n```\n$ git config --global --unset-all core.editor\n```\n\nTo edit the git config file via the default git editor:\n```\n$ git config --global --edit\n```\n\n## Concepts and terminology\n### Local Repository\nEvery version control system tool provides a private workplace as a working copy. Developers make \nchanges in their private workplace and after commit, these changes become a part of the repository. \nGit takes it one step further by providing them a private copy of the whole repository. Users can \nperform many operations with this repository such as add file, remove file, rename file, move file, \ncommit changes, and many more.\n\n### Working Directory and Staging Area or Index\nThe working directory is the place where files are checked out. Git does not track each and every \nmodified file. Whenever you do commit an operation, Git looks for the files present in the staging \narea. Only those files present in the staging area are considered for commit and not all the \nmodified files.\n\nLet us see the basic workflow of Git.\n\nStep 1 − You modify a file from the working directory.\n\nStep 2 − You add these files to the staging area.\n\nStep 3 − You perform commit operation that moves the files from the staging area. After push operation, \nit stores the changes permanently to the Git repository.\n\n![Basic workflow of Git](./assets/working-directory.png)\n\n### Blobs\nBlob stands for Binary Large Object. Each version of a file is represented by blob. A blob holds \nthe file data but does not contain any metadata about the file. It is a binary file, and in Git \ndatabase, it is named as SHA1 hash of that file. In Git, files are not addressed by names. \nEverything is content-addressed.\n\n### Trees\nTree is an object, which represents a directory. It holds blobs as well as other sub-directories. \nA tree is a binary file that stores references to blobs and trees which are also named as SHA1 hash \nof the tree object.\n\n### Commits\nCommit holds the current state of the repository. A commit is also named by SHA1 hash. You can consider \na commit object as a node of the linked list. Every commit object has a pointer to the parent commit \nobject. From a given commit, you can traverse back by looking at the parent pointer to view the \nhistory of the commit. If a commit has multiple parent commits, then that particular commit has been \ncreated by merging two branches.\n\n### Branches\nBranches are used to create another line of development. By default, Git has a master branch, which \nis same as trunk in Subversion. Usually, a branch is created to work on a new feature. Once the \nfeature is completed, it is merged back with the master branch and we delete the branch. Every branch \nis referenced by HEAD, which points to the latest commit in the branch. Whenever you make a commit, \nHEAD is updated with the latest commit.\n\n### Tags\nTag assigns a meaningful name with a specific version in the repository. Tags are very similar to \nbranches, but the difference is that tags are immutable. It means, tag is a branch, which nobody \nintends to modify. Once a tag is created for a particular commit, even if you create a new commit, \nit will not be updated. Usually, developers create tags for product releases.\n\n### Clone\nClone operation creates the instance of the repository. Clone operation not only checks out the \nworking copy, but it also mirrors the complete repository. Users can perform many operations with \nthis local repository. The only time networking gets involved is when the repository instances are \nbeing synchronized.\n\n### Pull\nPull operation copies the changes from a remote repository instance to a local one. The pull operation \nis used for synchronization between two repository instances. This is same as the update operation in \nSubversion.\n\n### Push\nPush operation copies changes from a local repository instance to a remote one. This is used to store \nthe changes permanently into the Git repository. This is same as the commit operation in Subversion.\n\n### HEAD\nHEAD is a pointer, which always points to the latest commit in the branch. Whenever you make a commit, \nHEAD is updated with the latest commit. The heads of the branches are stored in `.git/refs/heads/` \ndirectory.\n\n### Revision\nRevision represents the version of the source code. Revisions in Git are represented by commits. \nThese commits are identified by SHA1 secure hashes.\n\n### URL\nURL represents the location of the Git repository. Git URL is stored in config file.\n\n## Most widely used commands along with their use cases\nThis list contains some of the most widely used git commands, and is open for accepting contributions\n\n### git add\nThe git add command adds a change in the working directory to the staging area. It tells Git that \nyou want to include updates to a particular file in the next commit. Changes are not actually recorded \nuntil you run `git commit` after.\n\nTo add all changes of the mentioned file to the staging area:\n```\n$ git add \u003cfile\u003e\n```\n\nTo add all changes of the mentioned directory to the staging area:\n```\n$ git add \u003cdirectory\u003e\n```\n\nTo add all the changes in all the files to the staging area:\n```\n$ git add .\n```\n\n### git apply\nThe changes present in a patch file (e.g. the output of git diff) can be applied to the working directory \nby using the git apply command. With the `--index` option the patch is also applied to the index, \nand with the `--cached` option the patch is only applied to the index.\n```\n$ git apply \u003cpatch-file\u003e\n```\n\n\n### git branch\nIn Git, branches are effectively a pointer to a snapshot of your changes. When you want to add a new \nfeature or fix a bug no matter how big or how small you spawn a new branch to encapsulate your changes.\n\nList all the branches in your local repository (`git branch --list` can also be used to generate the same \noutput):\n```\n$ git branch\n```\n\nCreate a new branch locally. This does not check out the new branch:\n```\n$ git branch \u003cbranch\u003e\n```\n\nDelete the specified local branch. This is a “safe” operation in that Git prevents you from deleting the \nbranch if it has unmerged changes:\n```\n$ git branch -d \u003cbranch\u003e\n```\n\nForce delete the specified local branch, even if it has unmerged changes.\n```\n$ git branch -D \u003cbranch\u003e\n```\n\nRename the current local branch:\n```\n$ git branch -m \u003cnew-branch\u003e\n```\n\nList all the branches of the current repository both local and remote:\n```\n$ git branch -a\n```\n\nDeleting a remote branch:\n```\n$ git push origin --delete \u003cbranch\u003e\n```\nor\n```\n$ git push origin :\u003cbranch\u003e\n```\n\n### git checkout\nThe git checkout command operates upon three distinct entities: files, commits, and branches.\n\n**Checking out branches:**\n\nThe git checkout command lets you navigate between the branches created by git branch. Checking out a \nbranch updates the files in the working directory to match the version stored in that branch, and it \ntells Git to record all new commits on that branch.\n\nSwitch to an existing local branch:\n```\n$ git checkout \u003cbranch\u003e\n```\n\nCreate a new local branch and switch to it:\n```\n$ git checkout -b \u003cnew-branch\u003e (The \u003cnew-branch\u003e is based off of the current HEAD)\n```\n\nBy default git checkout -b will base the new-branch off the current HEAD. If an optional additional \nparameter is passed, then the new-branch is based off of branch specified instead of the current HEAD.\n```\n$ git checkout -b ＜new-branch＞ ＜existing-branch＞ (The \u003cnew-branch\u003e is based off of \u003cexisting-branch\u003e)\n```\n\nChecking out to a remote branch (In order to checkout a remote branch you have to first fetch the contents of the branch):\n```\n$ git fetch --all\n$ git checkout ＜remote-branch＞\n```\n\n**Checking out commits:**\n\nTo checkout a specific commit, you can use the git checkout command and provide the commit hash \nas a parameter:\n```\n$ git checkout \u003ccommit-hash\u003e (e.g. git checkout 123abc123)\n```\n\n**Checking out files:**\n\nThe git checkout command when used along with a file discards all the file changes in the working \ndirectory:\n```\n$ git checkout \u003cfile-name\u003e\n$ git checkout . (discards all the changes in all the modified files in the working directory)\n```\n\n### git clone\ngit clone is a Git command line utility which is used to target an existing repository and create a \nclone, or copy of the target repository.\n```\n$ git clone \u003crepo\u003e\n```\n\nCloning to a specific folder:\n```\n$ git clone \u003crepo\u003e \u003cdirectory\u003e\n```\n\nCloning a specific tag:\n```\n$ git clone --branch \u003ctag\u003e \u003crepo\u003e\n```\n\nCloning a specific branch:\n```\n$ git clone -b \u003cbranch\u003e \u003crepo\u003e\n```\n\n### git commit\nThe git commit command captures a snapshot of the project's currently staged changes. Committed \nsnapshots can be thought of as “safe” versions of a project—Git will never change them unless you \nexplicitly ask it to. Prior to the execution of git commit, The git add command is used to promote or \n'stage' changes to the project that will be stored in a commit.\n\nCommit the staged snapshot. This will launch a text editor prompting you for a commit message. \nAfter you’ve entered a message, save the file and close the editor to create the actual commit.\n```\n$ git commit\n```\n\nCommit with an inline message:\n```\n$ git commit -m \"Initial commit\"\n```\n\nInstead of creating a new commit, add/append staged changes to the previous commit:\n```\n$ git commit --amend\n```\n\n### git config\nThis command is used to display or set the config properties of git at various levels (system, global and local):\n\nList all the config properties:\n```\n$ git config --global --list (lists all the global git config properties)\n```\n\nDisplay the value of a property:\n```\n$ git config --local user.name\n```\n\nSet the value of a property:\n```\n$ git config --system color.ui false\n```\n\nAdd a value to an existing property without changing the previous values:\n```\n$ git config --global --add core.gitproxy '\"proxy-command\" for example.com'\n```\n\nTo remove or unset a config property:\n```\n$ git config --global --unset core.editor\n```\n\nTo remove or unset all the values of a property:\n```\n$ git config --global --unset-all core.editor\n```\n\nTo edit the git config file via the default git editor:\n```\n$ git config --system --edit\n```\n\n### git describe\nThe command finds the most recent tag that is reachable from a commit. If the tag points to the commit, \nthen only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits \non top of the tagged object and the abbreviated object name of the most recent commit.\n\nDescribing a branch:\n```\n$ git describe \u003cbranch\u003e\n```\nThe above outputs the tag that the branch is based on along with the number of commits on top and an \nabbreviated object name for the commit at the end.\n\nDescribing a tag:\n```\n$ git describe \u003ctag\u003e\n```\n\n### git diff\ngit diff is a multi-use Git command that when executed runs a diff function on Git data sources. \nThese data sources can be commits, branches, files and more.\n\nChanges since last commit:\n```\n$ git diff\n```\n\nComparing files between two different commits:\n```\n$ git diff \u003ccommit-hash-1\u003e \u003ccommit-has-2\u003e\n```\n\nComparing two branches:\n```\n$ git diff \u003cbranch-1\u003e \u003cbranch-2\u003e\n```\n\nComparing files from two branches:\n```\n$ git diff\u003cbranch-1\u003e \u003cbranch-2\u003e \u003cfile-path\u003e\n```\n\n### git fetch\nThe git fetch command is used to pull the updates from remote-tracking branches. Additionally, we \ncan get the updates that have been pushed to our remote branches to our local machines.\n\nTo fetch the remote repository:\n```\n$ git fetch \u003crepository-url\u003e\n```\n\nTo fetch a specific branch:\n```\n$ git fetch \u003cbranch-url\u003e \u003cbranch\u003e\n```\n\nTo fetch all the branches simultaneously:\n```\n$ git fetch --all\n```\n\nTo synchronize the local repository:\n```\n$ git fetch origin\n```\n\n### git init\nThe git init command creates a new Git repository. It can be used to convert an existing, unversioned \nproject to a Git repository or initialize a new, empty repository. Executing git init creates a .git \nsubdirectory in the current working directory, which contains all of the necessary Git metadata for \nthe new repository. This metadata includes subdirectories for objects, refs, and template files. A HEAD \nfile is also created which points to the currently checked out commit.\n\nTo transform the current directory into a Git repository:\n```\n$ git init\n```\n\nCreate an empty Git repository in the specified directory. Running this command will create a new \nsubdirectory containing nothing but the .git subdirectory:\n```\n$ git init \u003cdirectory\u003e\n```\n\nInitialize an empty Git repository, but omit the working directory. Shared repositories should always \nbe created with the --bare flag (see discussion below). Conventionally, repositories initialized with \nthe --bare flag end in .git:\n```\n$ git init --bare \u003cdirectory\u003e\n```\n\nInitialize a new Git repository and copy all the .git files from the **template-directory** into the new \nrepository:\n```\n$ git init \u003cdirectory\u003e --template=\u003ctemplate-directory\u003e\n```\n\nUsing the `--quiet` option, we can only print \"critical level\" messages, errors, and warnings. All other \noutput is silenced:\n```\n$ git init --quiet\n```\n\n### git log\nGit log is a utility tool to review and read a history of everything that happens to a repository.\n\nThe basic git log command will display the most recent commits and the status of the head:\n```\n$ git log\n```\n\nThe `--oneline` option is used to display the output as one commit per line. It also shows the output \nin brief like the first seven characters of the commit SHA and the commit message:\n```\n$ git log --oneline\n```\n\nThe `--stat` option displays the files that have been modified. It also shows the number of lines and a \nsummary line of the total records that have been updated:\n```\n$ git log --stat\n```\n\nThe `--patch` or `-p` option displays the files that have been modified. It also shows the location \nof the added, removed, and updated lines:\n```\n$ git log --patch\n```\nor\n```\n$ git log -p\n```\n\nShowing the git log as a graph using `--graph` option:\n```\n$ git log --graph\n```\n\n**Git log command to filter out commit history**\nBy amount:\n```\n$ git log -n (will print the log of \"n\" recent commits)\n```\n\nBy date and time:\n```\n$ git log --after=\"yyyy-mm-dd\"\n```\nor\n```\n$ git log --after=\"21 days ago\"\n```\nor\n```\n$ git log --after=\"yyyy-mm-dd\" --before=\"yyyy-mm-dd\"\n```\n\nBy Author:\n```\n$ git log --author=\u003cauthor-name\u003e\n```\n\nBy commit message:\n```\n$ git log --grep=\u003ccommit-message\u003e\n```\n\nBy file:\n```\n$ git log -- \u003cfile-1\u003e \u003cfile-2\u003e (displays the commit logs of the files file-1 and file-2)\n```\n\n### git merge\nThe git merge command lets you take the independent lines of development created by git branch and \nintegrate them into a single branch.\n\nNote that all of the commands presented below merge into the current branch. The current branch will be \nupdated to reflect the merge, but the target branch will be completely unaffected. Make sure that both \nthe branches are up to date with the remote repository before doing a merge. If there are conflicts \nin the merge operation, then it results in a merge conflict.\n\nTo merge the specified commit to currently active branch:\n```\n$ git merge \u003ccommit\u003e\n```\n\nTo merge the speciified branch into the currently active branch:\n```\n$ git merge \u003cbranch-name\u003e (\u003cbranch-name\u003e is the branch whose changes are merged into the current branch)\n```\n\n### git mv\nThis command is used to move or rename a file or directory. The file or directory that has to be moved \nor renamed has to be present in the staging area.\n\nTo rename a file or directory:\n```\n$ git mv \u003cfile-1\u003e \u003cfile-2\u003e (to rename a file)\n```\nor\n```\n$ git mv \u003cdirectory-1\u003e \u003cdirectory-2\u003e (to rename a directory)\n```\n\nTo move a file or directory:\n```\n$ git mv \u003csource-file\u003e \u003cdestination-file\u003e (to move a file)\n```\nor\n```\n$ git mv \u003csource-directory\u003e \u003cdestination-directory\u003e (to move a directory)\n```\n\n### git notes\nThis command adds, removes, or reads notes attached to objects, without touching the objects themselves.\nBy default, notes are saved to and read from `refs/notes/commits`, but this default can be overridden.\n\nList notes of any object:\n```\n$ git notes list (lists notes of all the objects)\n$ git notes list \u003cobject\u003e ((lists notes of the object specified)\n```\n\nAdd notes to an object:\n```\n$ git notes add -m \"note contents\" \u003cobject\u003e (if object is not specified the default is taken as HEAD)\n```\nNote: If there is an already existing notes for an object, then the add command gives an error. If the \n`--force` or `-f` option is used along with the add command, it overrides the existing notes and creates a \nnew one.\n\nAppend to the notes of an existing object (defaults to HEAD). Creates a new notes object if needed:\n```\n$ git notes append -m \"note contents\" \u003cobject\u003e (if object is not specified the default is taken as HEAD)\n```\n\nShow notes of an object:\n```\n$ git notes show \u003cobject\u003e (if object is not specified the default is taken as HEAD)\n```\n\nEdit notes of an object:\n```\n$ git notes edit \u003cobject\u003e (if object is not specified the default is taken as HEAD)\n```\n\nRemove the notes for given object:\n```\n$ git notes remove \u003cobject\u003e (if object is not specified the default is taken as HEAD)\n```\n\nRemove all the notes of all the objects:\n```\n$ git notes prune\n```\n\n### git pull\nThe `git pull` command is used to fetch and download content from a remote repository and immediately update \nthe local repository to match that content. The git pull command first runs git fetch which downloads content \nfrom the specified remote repository. Then a git merge is executed to merge the remote content refs and heads \ninto a new local merge commit.\n\nPull changes from a remote branch (Fetch the specified remote’s copy of the current branch and immediately \nmerge it into the local copy):\n```\n$ git pull \u003cremote\u003e\n```\n\nFetch the remote content but does not create a new merge commit:\n```\n$ git pull --no-commit \u003cremote\u003e\n```\n\nPulling with rebase instead of merge:\n```\n$ git pull --rebase \u003cremote\u003e\n```\n\nOutput the content being downloaded and the merge details during the pull:\n```\n$ git pull --verbose\n```\n\n### git push\nThe git push command is used to upload local repository content to a remote repository.\n\nPush changes to the specified remote and branch:\n```\n$ git push \u003cremote\u003e \u003cbranch\u003e\n```\n\nPush all of your local branches to the specified remote:\n```\n$ git push \u003cremote\u003e --all\n```\n\nTags are not automatically pushed using the push command, in order to push local tags:\n```\n$ git push \u003cremote\u003e --tags\n```\n\n### git rebase\nRebasing is the process of moving or combining a sequence of commits to a new base commit.\n\nRebase the current branch onto the specified base, which can be any kind of commit reference(for example an ID, \na branch name, a tag, or a relative reference to HEAD):\n```\n$ git rebase \u003cbase\u003e\n```\n\n### git remote\nThe `git remote` command manages the set of remotes that you are tracking with your local repository.\n\nList the current remotes associated with the local repository:\n```\n$ git remote -v\n```\n\nAdding a remote:\n```\n$ git remote add \u003cname\u003e \u003curl\u003e\n```\n\nRemoving a remote:\n```\n$ git remote remove \u003cname\u003e\n```\n\n### git replace\nThe replace command lets you specify an object in Git and say \"every time you refer to this object, pretend it’s \na different object\".\n```\n$ git replace \u003cobject\u003e \u003creplacement\u003e\n```\n\n### git reset\n### git restore\n### git revert\n### git rm\n### git show\n### git stash\n### git status\n### git switch\n### git tag\n\n## Miscellaneous\n### The `.gitignore` file\nGit sees every file in your working copy as one of three things:\n\n - tracked - a file which has been previously staged or committed\n - untracked - a file which has not been staged or committed or\n - ignored - a file which Git has been explicitly told to ignore.\n\nIf you don't want to commit some files/folders to Git, and want Git to completely ignore them, then \nyou can have a file called **.gitignore** created at the root of your repository and add file/folder \npatterns to ignore. All the files/folders that match the patterns mentioned in the **.gitignore** \nfile are completely ignored by Git. Refer this link: \n[https://linuxize.com/post/gitignore-ignoring-files-in-git](https://linuxize.com/post/gitignore-ignoring-files-in-git)\nto know more about patterns that can be used in the **.gitignore** file.\n\n### `git fetch` vs `git pull`\n`git fetch` really only downloads new data from a remote repository - but it doesn't integrate any of this \nnew data into your working files. Fetch is great for getting a fresh view on all the things that happened \nin a remote repository. Due to it's \"harmless\" nature, fetch will never manipulate, destroy, or \nscrew up anything.\n\n`git pull` in contrast, is used with a different goal in mind: to update your current HEAD branch with \nthe latest changes from the remote server. This means that pull not only downloads new data, it also \ndirectly integrates it into your current working copy files. This has a couple of consequences:\n - Since `git pull` tries to merge remote changes with your local ones, a so-called \"merge conflict\" \n  can occur.\n - Like for many other actions, it's highly recommended to start a \"git pull\" only with a clean \n   working copy. This means that you should not have any uncommitted local changes before you pull.\n\n## References\n - [https://git-scm.com/docs](https://git-scm.com/docs)\n - [https://www.atlassian.com/git/tutorials](https://www.atlassian.com/git/tutorials)\n - [https://github.com/git-guides](https://github.com/git-guides)\n - [https://www.tutorialspoint.com/git](https://www.tutorialspoint.com/git/git_basic_concepts.htm)\n - [https://linuxize.com/post/gitignore-ignoring-files-in-git](https://linuxize.com/post/gitignore-ignoring-files-in-git)\n - [https://www.git-tower.com/learn/git/faq](https://www.git-tower.com/learn/git/faq)\n - [https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/The-global-Git-config-files-key-settings-and-usages](https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/The-global-Git-config-files-key-settings-and-usages)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedgulabkhan%2Fgit-for-noobs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmedgulabkhan%2Fgit-for-noobs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedgulabkhan%2Fgit-for-noobs/lists"}