Introduction:
Git & GitHub has steadily risen from being just a preferred skill to a must-have skill for multiple job roles today. In this article, I will talk about the Top 30 Git Commands that you will be using frequently while you are working with Git.
๐ Essential GitHub Commands Every DevOps Engineer Should Know
1. git init
๐ ๏ธ Description: Initializes a new Git repository in the current directory.
2. git clone [url]
๐ ๏ธ Description: Clones a repository into a new directory.
3. git add [file]
๐ ๏ธ Description: Adds a file or changes in a file to the staging area.
4. git commit -m "[message]"
๐ ๏ธ Description: Records changes to the repository with a descriptive message.
5. git push
๐ ๏ธ Description: Uploads local repository content to a remote repository.
6. git pull
๐ ๏ธ Description: Fetches changes from the remote repository and merges them into the local branch.
7. git status
๐ ๏ธ Description: Displays the status of the working directory and staging area.
8. git branch
๐ ๏ธ Description: Lists all local branches in the current repository.
9. git checkout [branch]
๐ ๏ธ Description: Switches to the specified branch.
10. git merge [branch]
๐ ๏ธ Description: Merges the specified branch's history into the current branch.
11. git remote -v
๐ ๏ธ Description: Lists the remote repositories along with their URLs.
12. git log
๐ ๏ธ Description: Displays commit logs.
13. git reset [file]
๐ ๏ธ Description: Unstages the file, but preserves its contents.
14. git rm [file]
๐ ๏ธ Description: Deletes the file from the working directory and stages the deletion.
15. git stash
๐ ๏ธ Description: Temporarily shelves (or stashes) changes that haven't been committed.
16. git tag [tagname]
๐ ๏ธ Description: Creates a lightweight tag pointing to the current commit.
17. git fetch [remote]
๐ ๏ธ Description: Downloads objects and refs from another repository.
18. git merge --abort
๐ ๏ธ Description: Aborts the current conflict resolution process, and tries to reconstruct the pre-merge state.
19. git rebase [branch]
๐ ๏ธ Description: Reapplies commits on top of another base tip, often used to integrate changes from one branch onto another cleanly.
20. git config --global user.name "[name]"
and git config --global user.email "[email]"
๐ ๏ธ Description: Sets the name and email to be used with your commits.
21. git diff
๐ ๏ธ Description: Shows changes between commits, commit and working tree, etc.
22. git remote add [name] [url]
๐ ๏ธ Description: Adds a new remote repository.
23. git remote remove [name]
๐ ๏ธ Description: Removes a remote repository.
24. git checkout -b [branch]
๐ ๏ธ Description: Creates a new branch and switches to it.
25. git branch -d [branch]
๐ ๏ธ Description: Deletes the specified branch.
26. git push --tags
๐ ๏ธ Description: Pushes all tags to the remote repository.
27. git cherry-pick [commit]
๐ ๏ธ Description: Picks a commit from another branch and applies it to the current branch.
28. git fetch --prune
๐ ๏ธ Description: Prunes remote tracking branches no longer on the remote.
29. git clean -df
๐ ๏ธ Description: Removes untracked files and directories from the working directory.
30. git submodule update --init --recursive
๐ ๏ธ Description: Initializes and updates submodules recursively.
Thank you for reading my blog โฆ:)
ยฉ Copyrights: ProDevOpsGuy
Top comments (0)