Git Commands For Devops and Cloud 1703998791
Git Commands For Devops and Cloud 1703998791
1. Cloning a Repository:
• Command (create and switch to the new branch): git checkout -b <branch name>
6. Committing Changes:
9. Merging Branches:
• Command (switch to the branch you want to merge into): git checkout <branch
name>
• When conflicts occur during a merge, manually edit the conflicting files to resolve
the conflicts. Then, add and commit the changes.
• Command (switch to the branch you want to rebase onto): git checkout <branch
name>
• Command (annotated tag with a message): git tag -a <tag name> -m "Tag message"
• Command (show a summarized view of the commit history): git log --oneline
• Command (undo the last commit and keep the changes locally): git reset HEAD~ •
Command (undo the last commit and discard the changes): git reset --hard HEAD~
• Command (rename/move a file): git mv <old file name> <new file name>
• Command (add a remote repository): git remote add <remote name> <repository
URL>
name>
• Command (apply a commit from another branch): git cherry-pick <commit hash>
➢ Repository (Repo): A repository is a collection of files and version history managed by Git. It
can be local (on your computer) or remote (on a server).
➢ Commit: A commit is a snapshot of the changes made to the files in a repository at a
specific point in time. Each commit has a unique identifier.
➢ Branch: A branch is a separate line of development within a repository. It allows developers
to work on different features or fixes without affecting the main codebase.
➢ Merge: Merging is the process of combining changes from one branch into another. This is
typically done to incorporate new features or bug fixes into the main branch.
what is GitHub?
➔GitHub, on the other hand, is a web-based platform that provides hosting for Git repositories. It
adds a web-based graphical interface, as well as features like issue tracking, collaboration tools, and
pull requests. GitHub allows developers to store and manage their Git repositories online, making it
easier to collaborate with others. It has become one of the most popular platforms for open-source
development and collaborative software projects.
Key features of GitHub include:
➢ Remote Repositories: GitHub allows you to host your Git repositories on its servers,
providing a centralized location for collaboration.
➢ Pull Requests: A pull request is a way to propose changes to a repository. It allows others to
review the proposed changes and merge them into the main branch.
➢ Pull Requests: A pull request is a way to propose changes to a repository. It allows others to
review the proposed changes and merge them into the main branch.
➢ Issues: GitHub provides a built-in issue tracking system, allowing developers to report and
discuss bugs, feature requests, and other topics.
➢ Wikis: GitHub repositories can include wikis for documentation and project-related
information.
➢ Actions: GitHub Actions enable you to automate workflows, such as building, testing, and
deploying your code directly from the repository.