DEV Community

BK Mahapatra
BK Mahapatra

Posted on • Updated on

Key Git Commands and Terminology Every Developer Should Know

Image by storyset on Freepik
Welcome to the Developer's Corner! 🚀 Dive into the heart of efficient version control with our latest blog post, where we unravel the key Git commands and terminology essential for every developer. Whether you're a coding maestro or just starting your programming journey, this comprehensive guide is your passport to mastering the intricacies of Git. Let's embark on a journey of streamlined collaboration, error-free code management, and a deeper understanding of version control. Gear up for an insightful exploration that will elevate your coding prowess! 💻✨ #GitCommands #DeveloperGuide #CodingMastery

Commands

  1. git config

    -to get and set Git configuration variables

  2. git config --global user.name "Your Name"

    -to set your user name

  3. git config --global user.email "your.email@example.com"

    -to set your user email

  4. git config user.name

    -to get you user name

  5. git config user.email

    -to get you user email

  6. git config --list

    -list all git configurations

  7. git config --global --edit

    -to edit the Git configuration file directly

  8. git init

    -This command initializes a new Git repository in the current directory.

  9. git add filename.txt

    -adds the specific file changes to the staging area

  10. git add .

    -adds all changes in the current directory and its subdirectories to the staging area in Git

  11. git add -p

    -to interactively choose which changes to add to the staging area

  12. git add --all :/ -:(filename.txt)

    -Add all changes but exclude some files:

  13. git rm filename.text

    -removes the specified file from both your working directory and the staging area.

  14. git commit -m “Your commit message”

    -to save the changes that have been added to the staging area

  15. git clone <repository_url>

    -to create a copy of a remote Git repository on your local machine

  16. git clone -b branch_name <repository_url>

    -to clone a repository from a specific branch,

  17. git fetch

    -It retrieves new branches, updates remote-tracking branches, and brings in the changes to your local repository.

  18. git pull <remote_name> <branch_name>

    -to fetch and merge changes from a remote repository into your current branch

  19. git push <remote_name> <branch_name>

    -to upload local repository content to a remote repository.

  20. git push -u <remote_name> <branch_name>

    -to push and set the default remote branch for future pushes.

  21. git push

    -to push the changes to default remote branch

  22. git push <remote_name> <local_branch_name>:<remote_branch_name>

    -to push a specific local branch to a different remote branch

  23. git push --all <remote_name>

    -pushes all local branches to the remote repository

  24. git push <remote_name> --delete <branch_name>

    -to delete a remote branch

  25. git push --force <remote_name> <branch_name>

    -forcefully updates a remote branch, potentially overwriting conflicting changes with caution to avoid data loss.

  26. git remote

    -lists the names of the remote repositories associated with your local repository

  27. git remote -v

    -shows the full URLs of remote repositories along with their names

  28. git branch -r

    -to view all remote-tracking branches in your local Git repository

  29. git remote add <name> <url>

    -adds a new remote repository

  30. git remote remove <name>

    -removes the remote repository with the specified name from your configuration

  31. git remote rename <old_name> <new_name>

    -renames a remote repository

  32. git remote show <name>

    -shows information about a specific remote repository, including the URL and branches

  33. git branch

    -lists all the branches in your local repository.

  34. git branch <branch_name>

    -creates a new branch with the specified name

  35. git checkout <branch_name>

    -switches to the specified branch

  36. git checkout -b <branch_name>

    -create and switches to the new branch

  37. git branch -d <branch_name>

    -deletes the specified branch

  38. git branch -m <old_branch_name> <new_branch_name>

    -renames the specified branch

  39. git merge <source_branch>

    -merges changes from [ source_branch ] into the current branch

  40. git log

    -shows a log of all commits in the repository, including their commit messages and unique identifiers

  41. git log --summary

    -provides a more detailed summary of each commit, including a list of changed files and the changes made to each file

  42. git status

    -gives a quick overview of changes in the working directory, files staged for the next commit, and untracked files in your Git repository

Top comments (0)