git切换分支
$ git branch -a
* master
dev
remotes/origin/HEAD -> origin/master
remotes/origin/dev
remotes/origin/master
## 切换到origin/dev分支命令本地分支为”dev”
$ git checkout -b dev origin/dev
.gitignore add
git rm -r --cached . // 删除本地缓存
git add . // 添加要提交的文件
git commit -m 'update .gitignore' // 更新本地的缓存
create a new repository on the command line
echo "# www" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/KelvinFanXian/www.git
git push -u origin master
push an existing repository from the command line
git remote add origin https://github.com/KelvinFanXian/www.git
git push -u origin master
clone私有库 ref
git clone http://username:password@onboard.com/srv/git/repo.git
list
command | desc |
---|---|
clone | 下载 |
add <file> | stage (to update what will be committed) |
commit -am 'message' |
stage(只限修改和删除,不包括新文件)并提交 |
push | 将commit推到服务端 |
pull | 从服务端拉取 |
status |
查看状态 |
log |
查看提交记录 |
--help | 查看手册 |
checkout -b <branch-name> <tag> | 创建分支 |
update-index --assume-unchanged <file> |
假装没改变 (忽略个性化配置文件) |
update-index --no-assume-unchanged <file> | 取消 假装没改变
|
reset HEAD <file> | to unstage |
checkout -- <file> | to discard changes in working directory |
协作需要谨记操作顺序:
git status
git add .
git commit
git pull
git push
ref
切换远程仓库
## 查看当前
git romote -v
## 修改
git remote set-url origin new_url