𝐁𝐚𝐬𝐢𝐜 𝐜𝐨𝐦𝐦𝐚𝐧𝐝 𝐨𝐟 𝐆𝐢𝐭

Megha Sharma - Oct 8 - - Dev Community

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.

. . . . . . . . . . . . . . . . . . .
Terabox Video Player