前端 git 使用总结

548 阅读1分钟

0.基本用法

git clone https://github.com/a.git
git add . 
git commit -m"注释"
git status
git log
git pull
git push

1.查看远程分支

git branch -a

	$ git branch -a
	* br-2.1.2.2
	  master
	  remotes/origin/HEAD -> origin/master
	  remotes/origin/br-2.1.2.1
	  remotes/origin/br-2.1.2.2
	  remotes/origin/br-2.1.3

2.查看本地分支

git branch

	$ git branch
	* br-2.1.2.2
	  master

3.创建分支

git branch 分支名

	$ git branch test
	 
	$ git branch
	* br-2.1.2.2
	  master
	  test

4.切换分支

git checkout test

5.刷新分支

git fetch

6.版本回退

git reset head  --版本号

7.配置用户

git config --global user.name "xxx"
git config --global user.email "xxx"
git config --list

8.合并分支

git merge test //合并某分支到当前分支

9.对上一次的提交做修改

git commit --amend 

常见错误

fatal: Authentication failed for... //不弹出用户名和密码 解决办法
git config --system --unset credential.helper

可以重新填写用户名和密码进行提交了。参考:www.jianshu.com/p/8a7f257e0…

git flow

git flow 文档:https://www.git-tower.com

参考

feature(新建)->devloper

release(devloper)->devloper,master

hotfix(master)->devloper,master

将当前修改暂存

git stash

初始化

git flow init

新建feature下分支

git flow feature start editor-markdown

将当前修改释放

git stash pop

合并当前分支到devloper

git flow feature finish devloper

当vim出现时

在vim模式下输入

press "i"
write your merge message
press "esc"
write ":wq"
then press enter

"i" is for "insert", "esc" is the exit the insertion, and ":wq" is just "write" and "quit".

vsCode使用git

解决vscode反复输入用户名,密码的问题

第一步:git config --global credential.helper store
第二步:重启vsCode