# Git-Cookbook
**Repository Path**: leven-cn/git-cookbook
## Basic Information
- **Project Name**: Git-Cookbook
- **Description**: Git Cookbook.
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: https://leven-cn.github.io/git-cookbook/
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2022-08-27
- **Last Updated**: 2022-08-29
## Categories & Tags
**Categories**: Uncategorized
**Tags**: Git, cookbook, devops
## README
# Git Cookbook
**Git** is a free and open source **distributed** **version control system** (**VCS**) designed
to handle everything from small to very large projects with *speed* and *efficiency*.
Actually, it is used for *tracking changes* in any set of files,
usually used for coordinating work among programmers collaboritively developing source code
during software development, thus it is called *source code management system*, *SCM*.
Git was created by *Linus Torvalds* in *2005* for development of the Linux kernel,
with other kernel developers contributing to its initial development.
Since 2005, *Junio Hamano* has been the core maintainer.
## Recipes
- [Git Features](https://leven-cn.github.io/git-cookbook/recipes/git_features)
- [Git Quick Start](https://leven-cn.github.io/git-cookbook/recipes/git_quickstart)
- [Git Configuration](https://leven-cn.github.io/git-cookbook/recipes/git_config)
- [Git URL](https://leven-cn.github.io/git-cookbook/recipes/git_url)
- [Git Clone](https://leven-cn.github.io/git-cookbook/recipes/git_clone)
- [Git Workflow](https://leven-cn.github.io/git-cookbook/recipes/git_workflow)
- [Git whitespace errors](https://leven-cn.github.io/git-cookbook/recipes/git_whitespace_errors)
- [Git Handling Line Endings (CRLF)](https://leven-cn.github.io/git-cookbook/recipes/git_line_endings)
- [`git add`](https://leven-cn.github.io/git-cookbook/recipes/git_add)
- [`git rm`](https://leven-cn.github.io/git-cookbook/recipes/git_rm)
- [`git restore`](https://leven-cn.github.io/git-cookbook/recipes/git_restore)
- [`git commit`](https://leven-cn.github.io/git-cookbook/recipes/git_commit)
- [`git branch`](https://leven-cn.github.io/git-cookbook/recipes/git_branch)
***
- Log
- Version Difference
- Tag
- Remote Branch
- Patch
- Git Server (SSH-based)
***
## Log
```bash
git log
git log -p # Show difference
git log -p -N # Show difference among lastest N commits
```
## Version Difference
```bash
git diff ..
```
## Tag
```bash
git tag -a -m '' # e.g., git tag -a 'v0.1' -m 'v0.1 - Initial version'
git push --tag # Add remote tag
git push origin :refs/tags/ # Delete remote tag
```
## Remote Branch
```bash
git remote -v
```
### Delete Remote Branch
```bash
git push [-f] :
```
## Patch
### Create Git Patch
```bash
... (git commit -m)
git format-patch -M .patch
```
### Apply Git Patch
```bash
git am .patch
... (git add+commit)
```
### Create Standard Patch
```bash
... (git commit)
git diff > .patch
```
### Apply Standard Patch
```bash
git apply --check .patch
git apply .patch
... (git add+commit)
```
## Git Server (SSH-based)
```bash
mkdir .git
cd .git
git init --bare
git clone --bare .git
scp -r .git @:/
# On Git Server
sudo adduer git
sudo passwd git
ssh @
sudo adduser git
sudo passwd git
sudo chown git:git /
gpasswd -a git
```
## License
[MIT License](https://github.com/leven-cn/git-cookbook/blob/main/LICENSE)