# 基本命令

参考自[A Visual Git Reference](https://marklodato.github.io/visual-git-guide/index-en.html)

### init/add/commit

![Git Basic Commands](https://1383251095-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSBZ7iRcgEfJ0mS6HCTWK%2Fuploads%2Fgit-blob-707b8fbe86c5d11964d03e281961bb550cd2cf7f%2Fgit-basic-commands-1.png?alt=media)

![Git Basic Commands](https://1383251095-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSBZ7iRcgEfJ0mS6HCTWK%2Fuploads%2Fgit-blob-7ec962cad02cdb1a12053a0f36f1e1576a5e75b2%2Fgit-basic-commands-2.png?alt=media)

```bash
git init
git add .
git commit -m 'Version 1.0'
```

### diff

![Git Diff](https://1383251095-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSBZ7iRcgEfJ0mS6HCTWK%2Fuploads%2Fgit-blob-fbcf7cd2a3b327b335c15b935fbba16fe2923a97%2Fgit-diff.png?alt=media)

### merge

![Git Merge](https://1383251095-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSBZ7iRcgEfJ0mS6HCTWK%2Fuploads%2Fgit-blob-db008adae7ba1e5c22363b6dd7f2ec43da12c299%2Fgit-merge.png?alt=media)

```bash
# Start a new feature
git checkout -b new-feature main
# Edit some files
git add <file>
git commit -m "Start a feature"
# Edit some files
git add <file>
git commit -m "Finish a feature"
# Merge in the new-feature branch
git checkout main
git merge new-feature
git branch -d new-feature
```

### clone/pull/push

```bash
git clone git@github.com:xxx/xxx.git
# Do something
...
# Push to repo
git push
# ...Or pull from repo
git pull
```
