Spelling & Grammar Day 37

This commit is contained in:
Michael Cade 2022-06-26 12:10:40 +01:00
parent 02560a46a6
commit 3238841740

View File

@ -2,26 +2,26 @@
title: '#90DaysOfDevOps - Gitting to know Git - Day 37'
published: false
description: 90DaysOfDevOps - Gitting to know Git
tags: "devops, 90daysofdevops, learning"
tags: "DevOps, 90daysofdevops, learning"
cover_image: null
canonical_url: null
id: 1048707
---
## Gitting to know Git
Apoligies for the terrible puns in the title and throughout. I am surely not the first person to turn Git into a dad joke!
Apologies for the terrible puns in the title and throughout. I am surely not the first person to turn Git into a dad joke!
In the last two posts we learnt about version control systems, and some of the fundamental workflows of git as a version control system [Day 35](day35.md) Then we got git installed on our system, updated and configured. We also went a little deeper on the theory between Client-Server version control system and Git which is a distributed version control system [Day 36](day36.md).
In the last two posts we learnt about version control systems, and some of the fundamental workflows of git as a version control system [Day 35](day35.md) Then we got git installed on our system, updated and configured. We also went a little deeper into the theory between the Client-Server version control system and Git which is a distributed version control system [Day 36](day36.md).
Now we are going to run through some of the commands and use cases that we will all commonly see with git.
### Where to git help with git?
There is going to be times where you just cannot remember or just don't know the command you need to get things done with git. You are going to need help.
There are going to be times when you just cannot remember or just don't know the command you need to get things done with git. You are going to need help.
It goes without saying that google or any search engine is likely to be your first port of call when searching help.
Google or any search engine is likely to be your first port of call when searching for help.
Secondly the next place is going to be the official git site and the documentation. [git-scm.com/docs](http://git-scm.com/docs) Here you will find not only a solid reference to all the commands available but also lots of different resources.
Secondly, the next place is going to be the official git site and the documentation. [git-scm.com/docs](http://git-scm.com/docs) Here you will find not only a solid reference to all the commands available but also lots of different resources.
![](Images/Day37_Git1.png)
@ -29,7 +29,7 @@ We can also access this same documentation which is super useful if you are with
![](Images/Day37_Git2.png)
We can also in the shell use `git add -h` which is going to give us a short summary of the options we have available.
We can also in the shell use `git add -h` which is going to give us a summary of the options we have available.
![](Images/Day37_Git3.png)
@ -37,19 +37,19 @@ We can also in the shell use `git add -h` which is going to give us a short summ
"Git has no access control" - You can empower a leader to maintain source code.
"Git is too heavy" - Git has the ability to provide shallow repositories which basically means a reduced amount of history if you have large projects.
"Git is too heavy" - Git can provide shallow repositories which means a reduced amount of history if you have large projects.
### Real shortcomings
Not ideal for Binary files. Great for source code but not great for executable files or videos for example.
Git is not user friendly, the fact that we have to spend time talking about commands and functions of the tool is probably a key sign of that.
Git is not user-friendly, the fact that we have to spend time talking about commands and functions of the tool is probably a key sign of that.
Overall though, git is hard to learn, but easy to use.
Overall though, git is hard to learn but easy to use.
### The git ecosystem
I want to briefly cover the ecosystem around git but not deep dive into some of these areas but I think its important to note these here at a high level.
I want to briefly cover the ecosystem around git but not deep dive into some of these areas but I think it's important to note these here at a high level.
Almost all modern development tools support Git.
@ -57,21 +57,21 @@ Almost all modern development tools support Git.
- Team tools - Also mentioned around tools like Jenkins from a CI/CD point of view, Slack from a messaging framework and Jira for project management and issue tracking.
- Cloud Providers - All the large cloud providers support git, Microsoft Azure, Amazon AWS, Google Cloud Platform.
- Cloud Providers - All the large cloud providers support git, Microsoft Azure, Amazon AWS, and Google Cloud Platform.
- Git-Based services - Then we have the GitHub, GitLab and BitBucket of which we will cover in more detail later on. I have heard these services as the social network for code!
- Git-Based services - Then we have GitHub, GitLab and BitBucket which we will cover in more detail later on. I have heard of these services as the social network for code!
### The Git Cheatsheet
We have not covered most of these commands but having looked at some cheatsheets available online I wanted to document some of the git commands and what their purpose are. We don't need to remember these all, and with more hands on practice and using you will pick at least the git basics.
We have not covered most of these commands but having looked at some cheat sheets available online I wanted to document some of the git commands and what their purpose is. We don't need to remember these all, and with more hands-on practice and use you will pick at least the git basics.
I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) but writing them down and reading the description is a good way to get to know what the commands are as well as getting hands on in every day tasks.
I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) but writing them down and reading the description is a good way to get to know what the commands are as well as getting hands-on in everyday tasks.
### Git Basics
| Command | Example | Description |
| --------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| git init | `git init <directory>` | Create an empty git repository in specified directory. |
| git init | `git init <directory>` | Create an empty git repository in the specified directory. |
| git clone | `git clone <repo>` | Clone repository located at <repo> onto local machine. |
| git config | `git config user.name` | Define author name to be used for all commits in current repository `system`, `global`, `local` flag to set config options. |
| git add | `git add <directory>` | Stage all changes in <directory> for the next commit. We can also add <files> and <.> for everything. |
@ -85,14 +85,14 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
| Command | Example | Description |
| --------------- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| git revert | `git revert <commit>` | Create a new commit that undoes all of the changes made in <commit> then apply it to the current branch. |
| git reset | `git reset <file>` | Remove <file> from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes. |
| git reset | `git reset <file>` | Remove <file> from the staging area, but leave the working directory unchanged. This unstaged a file without overwriting any changes. |
| git clean | `git clean -n` | Shows which files would be removed from the working directory. Use `-f` in place of `-n` to execute the clean. |
### Git Rewriting History
| Command | Example | Description |
| --------------- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| git commit | `git commit --amend` | Replace the last commit with the staged changes and last commit combined. Use with nothing staged to edit the last commits message. |
| git commit | `git commit --amend` | Replace the last commit with the staged changes and the last commit combined. Use with nothing staged to edit the last commits message. |
| git rebase | `git rebase <base>` | Rebase the current branch onto <base>. <base> can be a commit ID, branch name, a tag, or a relative reference to HEAD. |
| git reflog | `git reflog` | Show a log of changes to the local repositorys HEAD. Add --relative-date flag to show date info or --all to show all refs. |
@ -117,7 +117,7 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
| Command | Example | Description |
| --------------- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| git diff HEAD | `git diff HEAD` | Show difference between working directory and last commit. |
| git diff HEAD | `git diff HEAD` | Show the difference between the working directory and the last commit. |
| git diff --cached | `git diff --cached` | Show difference between staged changes and last commit |
### Git Config
@ -140,22 +140,22 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
| Command | Example | Description |
| ------------------------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| git pull --rebase <remote> | `git pull --rebase <remote>` | Fetch the remotes copy of current branch and rebases it into the local copy. Uses git rebase instead of merge to integrate the branches. |
| git pull --rebase <remote> | `git pull --rebase <remote>` | Fetch the remotes copy of current branch and rebases it into the local copy. Uses git rebase instead of the merge to integrate the branches. |
### Git Reset
| Command | Example | Description |
| ------------------------- | --------------------------| --------------------------------------------------------------------------------------------------------------------------------------------- |
| git reset | `git reset ` | Reset staging area to match most recent commit, but leave the working directory unchanged. |
| git reset | `git reset ` | Reset the staging area to match the most recent commit but leave the working directory unchanged. |
| git reset --hard | `git reset --hard` | Reset staging area and working directory to match most recent commit and overwrites all changes in the working directory |
| git reset <commit> | `git reset <commit>` | Move the current branch tip backward to <commit>, reset the staging area to match, but leave the working directory alone |
| git reset <commit> | `git reset <commit>` | Move the current branch tip backwards to <commit>, reset the staging area to match, but leave the working directory alone |
| git reset --hard <commit> | `git reset --hard <commit>` | Same as previous, but resets both the staging area & working directory to match. Deletes uncommitted changes, and all commits after <commit>. |
### Git Push
| Command | Example | Description |
| ------------------------- | --------------------------| --------------------------------------------------------------------------------------------------------------------------------------------- |
| git push <remote> --force | `git push <remote> --force` | Forces the git push even if it results in a non-fast-forward merge. Do not use the --force flag unless youre absolutely sure you know what youre doing. |
| git push <remote> --force | `git push <remote> --force` | Forces the git push even if it results in a non-fast-forward merge. Do not use the --force flag unless youre sure you know what youre doing. |
| git push <remote> --all | `git push <remote> --all` | Push all of your local branches to the specified remote. |
| git push <remote> --tags | `git push <remote> --tags` | Tags arent automatically pushed when you push a branch or use the --all flag. The --tags flag sends all of your local tags to the remote repo. |
@ -169,5 +169,4 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
- [Complete Git and GitHub Tutorial](https://www.youtube.com/watch?v=apGV9Kg7ics)
- [Git cheatsheet](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet)
See you on [Day 38](day38.md)
See you on [Day 38](day38.md)