GitHub - 30 GitHub commands used by every DevOps Engineer

ยท

3 min read

GitHub - 30 GitHub commands used by every DevOps Engineer

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

Join Our Telegram Community || Follow me for more DevOps Content

ย