πŸ› οΈ Essential Git Commands for Professional Employers 🌟

Hey Devs! πŸš€ Level up your Git game with these essential commands. Whether you’re starting a new project, managing branches, or pushing changes, these commands have got you covered. Let’s dive in! πŸŠβ€β™‚οΈ

1. git init – Initialize a New Git Repository πŸ—ƒ…


This content originally appeared on DEV Community and was authored by Sachin Gadekar

Hey Devs! πŸš€ Level up your Git game with these essential commands. Whether you’re starting a new project, managing branches, or pushing changes, these commands have got you covered. Let’s dive in! πŸŠβ€β™‚οΈ

1. git init - Initialize a New Git Repository πŸ—ƒοΈ

The git init command creates a new Git repository. Start your project the right way!

git init

2. git remote add origin - Connect to a Remote Repository 🌍

Add a remote repository to your local Git setup with git remote add origin.

git remote add origin <remote_repository_URL>

3. git add . - Stage Changes for Commit πŸ“¦

Use git add . to add all changes in the working directory to the staging area.

git add .

4. git commit -m 'message' - Commit Your Changes πŸ’Ύ

Capture a snapshot of your project's staged changes with git commit.

git commit -m 'Your commit message'

5. git push - Push Changes to Remote πŸš€

Send your local changes to a remote repository with git push.

git push

6. git push origin <branch_name> - Push a Branch πŸ“€

Push a local branch to a remote repository with git push origin.

git push origin <branch_name>

7. VIM Editor Edit πŸ“

Edit a file in VIM editor by pressing Escape and then I.

VIM edit sticker

8. VIM Editor Save and Exit πŸ’Ύ

Save and exit in VIM editor by pressing Escape and entering :wq.

9. git log - View Commit History πŸ“œ

Display the committed snapshots with git log.

git log

--

10. git branch - List Branches 🌿

See all branches in your repository with git branch.

git branch

11. git branch <branch_name> - Create a New Branch 🌱

Create a new branch in your local repository with git branch.

git branch <branch_name>

12. git push origin <branch_name> - Push a Created Branch 🌍

Push a newly created branch from local to the remote repository with git push origin.

git push origin <branch_name>

13. git checkout -b <branch_name> - Create and Switch Branch πŸ”„

Create a new branch and switch to it with git checkout -b.

git checkout -b <branch_name>

14. git checkout <branch_name> - Switch Branches 🌟

Switch to a specified branch with git checkout.

git checkout <branch_name>

15. git push origin --delete <branch_name> - Delete a Remote Branch πŸ—‘οΈ

Delete a branch from the remote repository with git push origin --delete.

git push origin --delete <branch_name>

16. git branch --delete <branch_name> - Delete a Local Branch 🧹

Delete a branch from your local repository with git branch --delete.

git branch --delete <branch_name>

17. git restore --staged <file_name> - Unstage a File πŸ”„

Unstage a file with git restore --staged.

git restore --staged <file_name>

18. git reset - Unstage All Files πŸ—ƒοΈ

Unstage all files with git reset.

git reset

--

19. git reset --hard - Unstage and Reset Changes 🚨

Unstage and reset all changes from the working directory with git reset --hard.

git reset --hard

20. git rm -f <file_name> - Remove a File ❌

Remove a file from the staging area and working directory with git rm -f.

git rm -f <file_name>

--

21. git rm --cached <file_name> - Remove from Staging Area 🚫

Remove a file from the staging area only with git rm --cached.

git rm --cached <file_name>

--

22. git push --force - Force Push πŸš€

Forcefully push changes to a specific branch, ignoring conflicts with git push --force.

git push --force

23. git push origin --delete <branch_name> - Delete Remote Branch πŸ—‘οΈ

Delete a branch from the remote repository with git push origin --delete.

git push origin --delete <branch_name>

24. git branch -D <branch_name> - Force Delete Local Branch ⚑

Forcefully delete a branch from the local repository with git branch -D.

git branch -D <branch_name>

25. git pull origin master - Pull Latest Changes πŸ”„

Pull the latest changes from the master branch of the remote repository with git pull origin master.

git pull origin master
` 
---

**26. `git branch -m <old_branch_name> <new_branch_name>` - Rename Local Branch 🏷️**

Rename a branch in the local repository with `git branch -m`.


bash
git branch -m


---

**27. `git push origin :<old_name> <new_name>` - Rename Remote Branch ✨**

Rename a branch in the remote repository with `git push origin :<old_name> <new_name>`.


bash
git push origin :


---

**28. `git revert <commit_ID>` - Revert Changes πŸ”„**

Undo changes to a repository’s commit history with `git revert`.


bash
git revert

 --

**29. `git push` - Push Reverted Changes πŸš€**

Push reverted changes to the respective branch with `git push`.


bash
git push


---

**30. Git Detached HEAD πŸ”„**

In Git, a detached HEAD state occurs when the HEAD points to a specific commit instead of a branch.

---

**31. `git cherry-pick` - Cherry-Pick Commits πŸ’**

Apply changes from a specific commit to another branch with `git cherry-pick`.


bash
git cherry-pick





 <a href="https://www.buymeacoffee.com/gadekar950q" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>




This content originally appeared on DEV Community and was authored by Sachin Gadekar


Print Share Comment Cite Upload Translate Updates
APA

Sachin Gadekar | Sciencx (2024-08-07T16:59:26+00:00) πŸ› οΈ Essential Git Commands for Professional Employers 🌟. Retrieved from https://www.scien.cx/2024/08/07/%f0%9f%9b%a0%ef%b8%8f-essential-git-commands-for-professional-employers-%f0%9f%8c%9f-2/

MLA
" » πŸ› οΈ Essential Git Commands for Professional Employers 🌟." Sachin Gadekar | Sciencx - Wednesday August 7, 2024, https://www.scien.cx/2024/08/07/%f0%9f%9b%a0%ef%b8%8f-essential-git-commands-for-professional-employers-%f0%9f%8c%9f-2/
HARVARD
Sachin Gadekar | Sciencx Wednesday August 7, 2024 » πŸ› οΈ Essential Git Commands for Professional Employers 🌟., viewed ,<https://www.scien.cx/2024/08/07/%f0%9f%9b%a0%ef%b8%8f-essential-git-commands-for-professional-employers-%f0%9f%8c%9f-2/>
VANCOUVER
Sachin Gadekar | Sciencx - » πŸ› οΈ Essential Git Commands for Professional Employers 🌟. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/07/%f0%9f%9b%a0%ef%b8%8f-essential-git-commands-for-professional-employers-%f0%9f%8c%9f-2/
CHICAGO
" » πŸ› οΈ Essential Git Commands for Professional Employers 🌟." Sachin Gadekar | Sciencx - Accessed . https://www.scien.cx/2024/08/07/%f0%9f%9b%a0%ef%b8%8f-essential-git-commands-for-professional-employers-%f0%9f%8c%9f-2/
IEEE
" » πŸ› οΈ Essential Git Commands for Professional Employers 🌟." Sachin Gadekar | Sciencx [Online]. Available: https://www.scien.cx/2024/08/07/%f0%9f%9b%a0%ef%b8%8f-essential-git-commands-for-professional-employers-%f0%9f%8c%9f-2/. [Accessed: ]
rf:citation
» πŸ› οΈ Essential Git Commands for Professional Employers 🌟 | Sachin Gadekar | Sciencx | https://www.scien.cx/2024/08/07/%f0%9f%9b%a0%ef%b8%8f-essential-git-commands-for-professional-employers-%f0%9f%8c%9f-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.