Git Commands for DevOps
- Git allows for version control and tracking of files
- Git push command is used to push local changes to a remote repository.
- Clone is a process to download code from GitHub or other repositories using either HTTPS or SSH mechanism.
- The main differences between 'git clone' and 'git fork'
- Branching in git allows developers to work on large features without disrupting existing functionality.
- Branching and merging in Git
- Branching allows isolated work and prevents conflicts.
- Understanding the difference between git merge and git rebase
- Git rebase vs git merge
---------------------------------
- The course covers different aspects of devops, including fundamentals, Linux scripting, and basics of git.
- The video focuses on git commands useful for devops engineers.
- covers both UI and CLI usage of git.
- The process of initializing a git repository using CLI is explained.
- The .git folder is created to track and log the repository.
Git allows for version control and tracking of files
- Git tracks changes made to files during active development
- Git provides the ability to view and revert to previous versions of files
- Git commit messages help to document changes made
- Git status shows the current status of files being tracked
Git push command is used to push local changes to a remote repository.
- To use git push, you need to have a remote reference for your repository.
- If there is no remote reference, you can add it using the
git remote add command.
Clone is a process to download code from GitHub or other repositories using either HTTPS or SSH mechanism.
- Use '
git clone' command to pull code from GitHub or other repositories.
- HTTPS mechanism authenticates using password while SSH mechanism authenticates using public key.
- To clone using HTTPS, click on the copy button and provide GitHub password.
- To clone using SSH, generate a public-private key pair using 'SSH-keygen' command, copy the public key, and paste it in GitHub settings.
The main differences between '
git clone' and '
git fork'
- 'git clone' allows you to download a specific repository, whereas 'git fork' creates a copy of a repository
- Cloning allows you to collaborate with others on the same codebase, while forking enables you to create an independent version of a repository
- Cloning downloads the latest code, while forking gives you a snapshot copy of the code at the time of forking
Branching in git allows developers to work on large features without disrupting existing functionality.
- Developers create separate branches to work on
specific features or changes.
- Changes made in branch are tested and merged back into the main branch once they are confident in the functionality.
Branching and merging in Git
- The main purpose of branching is to isolate development activities.
- To merge branches, you can use
git merge, git rebase, or git cherry pick.
- Cherry pick is easy for one or two commits, but not practical for large numbers of commits.
- Git merge and git rebase are useful for merging large numbers of commits.
- The difference between git merge and git rebase is practical and can be understood by practicing.
Branching allows isolated work and prevents conflicts.
- Merge and rebase are two ways to combine changes from branches.
- Merge includes all changes, while rebase applies one branch's changes on top of another.
- Merge creates a commit with all changes together.
- Rebase updates commit history to make it look like changes were made sequentially.
- Merge shows all commits in the log, while rebase shows a linear history.
- Conflicts occur when the same file is changed in different branches.
Understanding the difference between
git merge and git rebase
- Git merge merges branches and updates changes
at the top, while git rebase updates changes be
fore the main branch
- Git merge does not maintain a linear commit order, while git rebase allows for a linear understanding of changes
Git rebase vs git merge
- Git rebase provides a linear commit history, while git merge does not.
- Use git rebase when you want to track commit history in a linear way.
- Use git merge when you don't need a linear commit history.
- Git rebase updates the other branch before your changes, while git merge updates your changes before the main branch.