DEV Community

Cover image for ๐๐š๐ฌ๐ข๐œ ๐œ๐จ๐ฆ๐ฆ๐š๐ง๐ ๐จ๐Ÿ ๐†๐ข๐ญ
Megha Sharma
Megha Sharma

Posted on

๐๐š๐ฌ๐ข๐œ ๐œ๐จ๐ฆ๐ฆ๐š๐ง๐ ๐จ๐Ÿ ๐†๐ข๐ญ

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.

๐Ÿ‘‰ Git Remove
git rm [file_name] The git rm command is used to remove files from the staging area in a Git repository.
git rm -r [file_name] This command is used to remove files from the staging area and working directory.

Top comments (0)