Git & GitHub Commands
Git & GitHub Commands
For DevOps practitioners, Git and GitHub are indispensable tools for managing
source code, automating workflows, and collaborating with team members.
Here are some of the most commonly used Git and GitHub commands in a DevOps
context:
Git Commands:
git init: Initializes a new Git repository locally.
git clone: Clones a repository from a remote server.
git add: Adds changes in the working directory to the staging area.
git commit: Records changes to the repository with a commit message.
git push: Uploads local repository content to a remote repository.
git pull: Fetches and merges changes from a remote repository to the local
repository.
git status: Displays the state of the working directory and the staging area.
git log: Shows the commit logs.
git branch: Lists, creates, or deletes branches in the local repository.
git checkout: Switches branches or restores files in the working directory to a
previous state.
git merge: Combines changes from one branch into another.
git remote: Manages connections to remote repositories.
git fetch: Downloads objects and refs from another repository.
git stash: Temporarily shelves changes for later use.
git rebase: Reapplies commits on top of another base tip.
git reset: Resets current HEAD to the specified state.
git config: Sets configuration options for Git.
git tag: Creates, lists, deletes, or verifies a tag object signed with GPG.
git diff: Shows changes between commits, commit and working tree, etc.
Jay Bhadreshwara
GitHub Commands:
git remote -v: Lists the URLs of the remote repository associated with your
repository.
git push origin <branch_name>: Pushes changes to a specific branch on
GitHub.
git pull origin <branch_name>: Pulls changes from a specific branch on
GitHub.
git fetch origin: Fetches objects and refs from a remote repository.
git merge origin/<branch_name>: Merges changes from a specific remote
branch into the current local branch.
git push --tags: Pushes all tags to the remote repository.
git clone <repository_url>: Clones a repository hosted on GitHub.
git pull --rebase: Fetches changes and rebases the current branch on top of
the fetched changes.
git pull --all: Fetches changes from all remote repositories and merges them
into the current branch.
git pull --prune: Fetches changes from the remote repository and removes
any remote-tracking branches that no longer exist on the remote.
In DevOps workflows, these commands are used extensively for version control,
continuous integration, continuous deployment, infrastructure as code, and
collaboration among team members. DevOps engineers often rely on these
commands to automate processes and ensure smooth and efficient development,
testing, and deployment pipelines.
Jay Bhadreshwara