Getting Started with Git-
๐ด๐ถ๐ ๐ถ๐ป๐ถ๐ : This is the very first command you'll need to use when starting a new project. It initializes a new Git repository in your current directory.
๐ด๐ถ๐ ๐ฐ๐น๐ผ๐ป๐ฒ <๐ฟ๐ฒ๐ฝ๐ผ> : To work on an existing project, you'll want to clone (copy) it to your local machine. This command does that.
๐ ๐ฎ๐ธ๐ฒ ๐๐ต๐ฎ๐ป๐ด๐ฒ๐
Git
๐ด๐ถ๐ ๐๐๐ฎ๐๐๐ : Before making or after making changes, it's good practice to check the status of your files. This command will show you any changes that are currently unstaged.
๐ด๐ถ๐ ๐ฎ๐ฑ๐ฑ <๐ณ๐ถ๐น๐ฒ๐ป๐ฎ๐บ๐ฒ> : After you've made some changes to your files, you'll want to stage them for a commit. This command adds a specific file to the stage.
๐ด๐ถ๐ ๐ฎ๐ฑ๐ฑ . ๐ผ๐ฟ ๐ด๐ถ๐ ๐ฎ๐ฑ๐ฑ -๐ : Instead of adding files one by one, you can add all your changed files to the stage with one command.
๐ด๐ถ๐ ๐ฐ๐ผ๐บ๐บ๐ถ๐ -๐บ "๐๐ผ๐บ๐บ๐ถ๐ ๐บ๐ฒ๐๐๐ฎ๐ด๐ฒ" : Now that your changes are staged, you can commit them with a descriptive message.
๐๐ฟ๐ฎ๐ป๐ฐ๐ต๐ถ๐ป๐ด
๐ด๐ถ๐ ๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต : This command will list all the local branches in your current repository.
๐ด๐ถ๐ ๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต <๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต๐ป๐ฎ๐บ๐ฒ> : This command creates a new branch.
๐ด๐ถ๐ ๐ฐ๐ต๐ฒ๐ฐ๐ธ๐ผ๐๐ <๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต๐ป๐ฎ๐บ๐ฒ> : If you want to switch to a different branch, use this command.
๐ด๐ถ๐ ๐บ๐ฒ๐ฟ๐ด๐ฒ <๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต๐ป๐ฎ๐บ๐ฒ> : Once you've finished making changes in a branch, you'll want to bring those changes into your main branch (usually master). This command does that.
๐ฅ๐ฒ๐บ๐ผ๐๐ฒ ๐ฅ๐ฒ๐ฝ๐ผ๐๐ถ๐๐ผ๐ฟ๐ถ๐ฒ๐
๐ด๐ถ๐ ๐ฝ๐๐๐ต ๐ผ๐ฟ๐ถ๐ด๐ถ๐ป <๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต๐ป๐ฎ๐บ๐ฒ> : This command sends your commits to the remote repository.
๐ด๐ถ๐ ๐ฝ๐๐น๐น : If other people are also working on your project, you'll want to keep your local repo up-to-date with their changes. This command fetches and merges any changes from the remote repository.
๐ด๐ถ๐ ๐ฟ๐ฒ๐บ๐ผ๐๐ฒ -๐ : To check which remote servers are connected with your local repository.
๐๐ฒ๐ ๐๐ถ๐ณ๐ณ๐ฒ๐ฟ๐ฒ๐ป๐ฐ๐ฒ๐
๐ด๐ถ๐ ๐ณ๐ฒ๐๐ฐ๐ต ๐๐ ๐ด๐ถ๐ ๐ฝ๐๐น๐น: Both download data from a remote repository. However, git fetch just downloads it without integrating it, while git pull also merges it into your local files.
๐ด๐ถ๐ ๐บ๐ฒ๐ฟ๐ด๐ฒ ๐๐ ๐ด๐ถ๐ ๐ฟ๐ฒ๐ฏ๐ฎ๐๐ฒ: Both incorporate changes from one branch to another. git merge combines the source and target branches via a new commit, whereas git rebase moves or combines commits to a new base, making a cleaner history.
๐ด๐ถ๐ ๐ฟ๐ฒ๐๐ฒ๐ ๐๐ ๐ด๐ถ๐ ๐ฟ๐ฒ๐๐ฒ๐ฟ๐: Both are used to undo changes. git reset discards local changes completely, while git revert undoes public changes by creating a new reversing commit, thereby preserving history.
Git is an extremely powerful tool with plenty more commands and options.
However, this guide gives you a good start and reference point as you continue to explore and leverage Git for your version control needs.
Top comments (0)