Git provides a powerful set of commands for version control and collaborative software development. Here are some basic Git commands that are commonly used in the version control workflow.
๐ ๐๐จ๐ง๐๐ข๐ ๐ฎ๐ซ๐ ๐๐ข๐ญ
`๐ ๐ข๐ญ ๐๐จ๐ง๐๐ข๐ โ ๐ ๐ฅ๐จ๐๐๐ฅ ๐ฎ๐ฌ๐๐ซ.๐ง๐๐ฆ๐ โ๐๐จ๐ฎ๐ซ ๐๐๐ฆ๐โ`: Sets the global username.
`๐ ๐ข๐ญ ๐๐จ๐ง๐๐ข๐ โ ๐ ๐ฅ๐จ๐๐๐ฅ ๐ฎ๐ฌ๐๐ซ.๐๐ฆ๐๐ข๐ฅ โ๐ฒ๐จ๐ฎ๐ซ.๐๐ฆ๐๐ข๐ฅ@๐๐ฑ๐๐ฆ๐ฉ๐ฅ๐.๐๐จ๐ฆโ`: Sets the global email.
๐ ๐๐ง๐ข๐ญ๐ข๐๐ฅ๐ข๐ณ๐ ๐ ๐๐๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ
`๐ ๐ข๐ญ ๐ข๐ง๐ข๐ญ` Initializes a new Git repository. This command is run once when you start a new project.
๐ ๐๐ฅ๐จ๐ง๐ ๐ ๐๐๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ
`๐ ๐ข๐ญ ๐๐ฅ๐จ๐ง๐ <๐ซ๐๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ_๐ฎ๐ซ๐ฅ>` Creates a copy of a remote repository on your local machine. This is the first command you run when you want to start working on an existing project.
๐ ๐๐ก๐๐๐ค ๐๐๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ ๐๐ญ๐๐ญ๐ฎ๐ฌ
`๐ ๐ข๐ญ ๐ฌ๐ญ๐๐ญ๐ฎ๐ฌ` Shows the status of changes as untracked, modified, or staged.
๐ ๐๐๐ ๐๐ก๐๐ง๐ ๐๐ฌ ๐ญ๐จ ๐๐ญ๐๐ ๐ข๐ง๐ ๐๐ซ๐๐
`๐ ๐ข๐ญ ๐๐๐ <๐๐ข๐ฅ๐ ๐ง๐๐ฆ๐>` Adds changes in a specific file to the staging area.
`๐ ๐ข๐ญ ๐๐๐ .` Adds all changes in the working directory to the staging area.
๐ ๐๐จ๐ฆ๐ฆ๐ข๐ญ ๐๐ก๐๐ง๐ ๐๐ฌ
`๐ ๐ข๐ญ ๐๐จ๐ฆ๐ฆ๐ข๐ญ -๐ฆ โ๐๐จ๐ฆ๐ฆ๐ข๐ญ ๐ฆ๐๐ฌ๐ฌ๐๐ ๐โ` Commits the changes in the staging area with a descriptive commit message.
๐ ๐๐ข๐๐ฐ ๐๐จ๐ฆ๐ฆ๐ข๐ญ ๐๐ข๐ฌ๐ญ๐จ๐ซ๐ฒ
`๐ ๐ข๐ญ ๐ฅ๐จ๐ ` Displays a log of commits, showing commit messages, authors, dates, and commit hashes.
๐ ๐๐ฉ๐๐๐ญ๐ ๐๐๐ฆ๐จ๐ญ๐ ๐๐๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ
`๐ ๐ข๐ญ ๐ฉ๐ฎ๐ฌ๐ก ๐จ๐ซ๐ข๐ ๐ข๐ง <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Pushes local commits to the remote repository.
`๐ ๐ข๐ญ ๐ฉ๐ฎ๐ฅ๐ฅ ๐จ๐ซ๐ข๐ ๐ข๐ง <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Fetches changes from the remote repository and merges them into the local branch.
๐ ๐๐๐ฆ๐จ๐ฏ๐ ๐๐ง๐ญ๐ซ๐๐๐ค๐๐ ๐
๐ข๐ฅ๐๐ฌ
`๐ ๐ข๐ญ ๐๐ฅ๐๐๐ง -๐ง` Shows a list of untracked files that will be removed.
`๐ ๐ข๐ญ ๐๐ฅ๐๐๐ง -๐` Removes untracked files from the working directory.
๐ ๐๐ซ๐๐๐ญ๐ ๐๐ง๐ ๐๐ฉ๐ฉ๐ฅ๐ฒ ๐๐๐ญ๐๐ก๐๐ฌ
`๐ ๐ข๐ญ ๐๐ข๐๐ > ๐ฉ๐๐ญ๐๐ก๐๐ข๐ฅ๐` Creates a patch file from changes.
`๐ ๐ข๐ญ ๐๐ฉ๐ฉ๐ฅ๐ฒ < ๐ฉ๐๐ญ๐๐ก๐๐ข๐ฅ๐` Applies changes from a patch file.
๐ ๐๐ง๐๐จ ๐๐ก๐๐ง๐ ๐๐ฌ
`๐ ๐ข๐ญ ๐ซ๐๐ฌ๐๐ญ <๐๐ข๐ฅ๐ ๐ง๐๐ฆ๐>` Unstages changes for a specific file.
`๐ ๐ข๐ญ ๐ซ๐๐ฌ๐๐ญ โ ๐ก๐๐ซ๐ ๐๐๐๐` Discards all changes in the working directory.
๐๐๐ซ๐ ๐๐ซ๐ ๐ฌ๐จ๐ฆ๐ ๐ฆ๐จ๐ซ๐ ๐๐จ๐ฆ๐ฆ๐๐ง๐๐ฌ ๐๐จ๐ซ ๐ฆ๐๐ง๐๐ ๐ข๐ง๐ ๐ญ๐ก๐ ๐๐ข๐ญ
๐ ๐๐ข๐๐ฐ ๐๐๐ฆ๐จ๐ญ๐ ๐๐๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ข๐๐ฌ
`๐ ๐ข๐ญ ๐ซ๐๐ฆ๐จ๐ญ๐ -๐ฏ` Lists the remote repositories configured for the current repository.
๐ ๐
๐๐ญ๐๐ก ๐๐ก๐๐ง๐ ๐๐ฌ ๐๐ซ๐จ๐ฆ ๐๐๐ฆ๐จ๐ญ๐
`๐ ๐ข๐ญ ๐๐๐ญ๐๐ก` Fetches changes from the remote repository without merging them into your working directory.
๐ ๐๐ฎ๐ฅ๐ฅ ๐๐ก๐๐ง๐ ๐๐ฌ ๐๐ซ๐จ๐ฆ ๐๐๐ฆ๐จ๐ญ๐
`๐ ๐ข๐ญ ๐ฉ๐ฎ๐ฅ๐ฅ ๐จ๐ซ๐ข๐ ๐ข๐ง <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Fetches changes and merges them into your local branch.
๐ ๐๐ซ๐๐๐ญ๐ ๐ ๐๐๐ฆ๐จ๐ญ๐ ๐๐ซ๐๐ง๐๐ก
`๐ ๐ข๐ญ ๐ฉ๐ฎ๐ฌ๐ก ๐จ๐ซ๐ข๐ ๐ข๐ง <๐ฅ๐จ๐๐๐ฅ_๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>:<๐ซ๐๐ฆ๐จ๐ญ๐_๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Pushes a local branch to create a new remote branch.
๐ ๐๐ง๐๐จ ๐ญ๐ก๐ ๐๐๐ฌ๐ญ ๐๐จ๐ฆ๐ฆ๐ข๐ญ
`๐ ๐ข๐ญ ๐ซ๐๐ฌ๐๐ญ ๐๐๐๐~1` Undoes the last commit, keeping the changes in your working directory.
๐ ๐๐ฆ๐๐ง๐ ๐ญ๐ก๐ ๐๐๐ฌ๐ญ ๐๐จ๐ฆ๐ฆ๐ข๐ญ
`๐ ๐ข๐ญ ๐๐จ๐ฆ๐ฆ๐ข๐ญ โ ๐๐ฆ๐๐ง๐` Adds changes to the previous commit and allows you to edit the commit message.
๐ ๐๐๐ ๐๐จ๐ ๐จ๐ ๐๐ก๐๐ง๐ ๐๐ฌ
`๐ ๐ข๐ญ ๐ฅ๐จ๐ ` Displays the commit history.
๐ ๐๐๐ ๐๐จ๐ ๐ฐ๐ข๐ญ๐ก ๐๐ซ๐๐ฉ๐ก๐ข๐๐๐ฅ ๐๐๐ฉ๐ซ๐๐ฌ๐๐ง๐ญ๐๐ญ๐ข๐จ๐ง
`๐ ๐ข๐ญ ๐ฅ๐จ๐ โ ๐ ๐ซ๐๐ฉ๐ก โ ๐จ๐ง๐๐ฅ๐ข๐ง๐ โ ๐๐ฅ๐ฅ` Shows a concise commit history with a graphical representation.
๐ ๐๐๐ ๐๐ก๐๐ง๐ ๐๐ฌ ๐ข๐ง ๐๐จ๐ซ๐ค๐ข๐ง๐ ๐๐ข๐ซ๐๐๐ญ๐จ๐ซ๐ฒ
`๐ ๐ข๐ญ ๐๐ข๐๐` Shows changes in the working directory that are not staged.