fix: Add syntax highlighting to code blocks

This commit is contained in:
Asocia
2021-12-08 16:31:46 +03:00
parent 871f28d44c
commit 089e6ebae8
41 changed files with 92 additions and 87 deletions

View File

@ -1,9 +1,9 @@
If you have an existing repository and want to add a new remote you can use this command:
```
```bash
git remote add <name> <url>
```
Example:
```
```bash
git remote add origin git@github.com:Asocia/til.git
git push -u origin my_branch
```

View File

@ -1,7 +1,7 @@
You can change author of your commits to anyone. Let's make all the commit's of the current repository Torvalds :D Luckily we know his email address so this will be very easy. Just run:
```
You can change author of your commits to anyone. Let's make all the commits of the current repository Torvalds's :D Luckily we know his email address so this will be very easy. Just run:
```bash
git filter-branch --env-filter '
OLD_EMAIL="akkayas17@itu.edu.tr"
OLD_EMAIL="old_email@domain.com"
CORRECT_NAME="Linus Torvals"
CORRECT_EMAIL="torvalds@linux-foundation.org"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]

View File

@ -1,6 +1,6 @@
You have a commit which contains a good code change but it is in another branch?
```
```bash
# pick the commit
git cherry-pick <sha>

View File

@ -4,18 +4,18 @@ I'm reading Pro Git book and I learn some cool stuff. I don't know if I'm going
If you to know which changes are made since some time, use `--since` option like:
```
```bash
git log --since=2.weeks
```
or until some time
```
```bash
git log --until="20-01-2020"
```
These commands works with lots of formats, you can specify a specific date like "2008-01-15", or a relative date such as "2 years 1 day 3 minutes ago"
The --author option allows you to filter on a specific author
```
```bash
git log --author="Asocia"
```
@ -23,7 +23,7 @@ git log --author="Asocia"
Another really helpful filter is the -S option (colloquially referred to as Gits “pickaxe” option), which takes a string and shows only those commits that changed the number of occurrences of that string. For instance, if you wanted to find the last commit that added or removed a reference to a specific function, you could call:
```
```bash
git log -S function_name
```
@ -33,11 +33,11 @@ git log -S function_name
Weve mentioned and given some demonstrations of how the git clone command implicitly adds the origin remote for you. Heres how to add a new remote explicitly. To add a new remote Git repository as a shortname you can reference easily, run git remote add <shortname> <url>:
```
$ git remote -v
$ git remote add pb https://github.com/paulboone/ticgit
$ git remote -v
$ git fetch pb
```bash
git remote -v
git remote add pb https://github.com/paulboone/ticgit
git remote -v
git fetch pb
```
Pauls master branch is now accessible locally as pb/master — you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.
@ -52,23 +52,23 @@ From Git version 2.23 onwards you can use `git switch` instead of `git checkout`
- Renaming branches
Suppose you have a branch that is called `bad-branch-name` and you want to change it to `corrected-branch-name`, while keeping all history. You also want to change the branch name on the remote (GitHub, GitLab, other server). How do you do this? Rename the branch locally with the `git branch --move` command:
```
```bash
git branch --move bad-branch-name corrected-branch-name
```
This replaces your `bad-branch-name` with `corrected-branch-name`, but this change is only local for now. To let others see the corrected branch on the remote, push it:
```
```bash
git push --set-upstream origin corrected-branch-name
```
To delete the old branch name:
```
```bash
git push origin --delete bad-branch-name
```
- Pushing a local branch into a remote branch that is named differently
```
```bash
# our branch is serverfix and we don't want to push it with this name
git push origin serverfix:awesomebranch
```

View File

@ -1,6 +1,6 @@
Let's say you are in `wip` branch and you didn't push your changes to server yet. If you want to get all the changes from master:
```
```bash
git checkout master
git pull
git checkout wip

View File

@ -1,10 +1,10 @@
When you do
```
```bash
git rebase -i commitish
```
and edit some commits, you will recreate the history hence all the commits coming after edited one will have the same date and time. If you don't want this behaviour here is the trick:
```
```bash
git rebase --committer-date-is-author-date -i commitish
```
Note that you need git version 23.19 or greater to do this in interactive mode.

View File

@ -1,7 +1,7 @@
From Pro Git book:
> Another useful thing you may want to do is to keep the file in your working tree but remove it from your staging area. In other words, you may want to keep the file on your hard drive but not have Git track it anymore. This is particularly useful if you forgot to add something to your .gitignore file and accidentally staged it, like a large log file or a bunch of .a compiled files. To do this, use the --cached option:
```
```bash
git rm --cached README
```

View File

@ -1,6 +1,6 @@
You can remove untracked files with `git-clean`.
```
```bash
# Show which files will be removed
git clean -nd

View File

@ -1,5 +1,5 @@
You can clone a repository with ssh and pull/push without having to enter your credentials. If you already cloned it with https and want to change your remote url, do this:
```
```bash
git remote -v
origin https://github.com/Asocia/dotfiles.git (fetch)
origin https://github.com/Asocia/dotfiles.git (push)

View File

@ -1,5 +1,5 @@
To see the changes in both staging area and working tree, use:
```
```bash
git diff HEAD
```

View File

@ -1,16 +1,16 @@
You can add filename to `git log` to view all the commit history of a file:
```
```bash
git log my_file
```
If you want to view diff's, add `-p` option:
```
```bash
git log -p my_file
```
If you want to continue listing the file history beyond renames, add `--follow` option:
```
```bash
git log --follow -p my_file
```