AWS Logo
Menu

šššš¬š¢šœ šœšØš¦š¦ššš§š šØšŸ š†š¢š­

"Learn Git basics: Initialize, add, commit, push. Lay the foundation for efficient version control and collaborative coding. #Git"

Published Feb 27, 2024
Last Modified Jul 4, 2024
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.
Ā 

Comments