✅ 基本使用

git init 创建仓库

mkdir xxx.git
cd xxx.git
git init --bare

git clone/staus/diff/log/show/push/pull/commit/add/checkout

git clone
git status
git log
git diff
git show
git push
git pull

git commit -m "add xxx"
git commit --amend

git add -A  # 提交所有变化
git add -u  # 提交被修改(modified)和被删除(deleted)文件,不包括新文件(new)
git add .  # 提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件

git checkout . #本地所有修改的。没有的提交的,都返回到原来的状态
							 #use "git checkout -- <file>..." 
							 #to discard changes in working directory

git remote

git remote -v
origin	<https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git> (fetch)
origin	<https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git> (push)

git remote show origin
* remote origin
  Fetch URL: <https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git>
  Push  URL: <https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git>
  HEAD branch: master
  Remote branches:
		akpm          tracked
    akpm-base     tracked
    master        tracked
    pending-fixes tracked
    stable        tracked
...

git remote set-url origin <url>

git branch/switch/merge 分支管理

#查看分支:
git branch

#创建分支:
git branch <name>

# 切换分支: 
git switch <name>   
git switch master
# 或者  git checkout <name> 

# 创建+切换分支:
git checkout -b <name> 

# 从 commit 创建分支
git checkout -b <name> [commit]
# 或者 git switch -c <name>

# 删除分支:
git branch -d <name>

✅ git branch

# list local branches
git branch 

# -r for remote
git branch -r

# -a for both local and remote
git branch -a
# 创建一个远程分支
git branch -r
	origin/HEAD -> origin/master
  origin/master

git checkout -b new1
echo "Hello" > new1
git add -A
git commit -m "new1"
git push --set-upstream origin new1

git branch -r
	origin/HEAD -> origin/master
  origin/master
  **origin/new1**