git开发遇到的常用用法


git config --local user.name "cc"

git config --global user.name "cc"

git config --local user.email "[email protected]"


git commit --amend -m  'xxx' 


ssh-copy-id -p 22701 [email protected] 


$git branch -d bugfix-v1.0.0.170718

$git push origin  --delete :bugfix-v1.0.0.170718


git rm --cached examples/frameworkdemo/client/client 


git reset --hard e377f60e28c8b84158


ssh-copy-id -p 22891 [email protected]


git remote set-url origin ssh://spb_git/home/git/gitcodes/spacebook.git

git remote add origin [email protected]:YotrolZ/helloTest.git


git push -u origin master -f


先将对方的代码fork到自己的GitHub上
直接在对方GitHub仓库里fork就好。

从自己的GitHub上fork代码并clone到本地
git clone https://github.com/你自己的GitHub账户名/git_coroperation_test
例如我的:git clone https://github.com/Sevenkili/git_coroperation_test
进入到clone到的本地仓库里
cd git_coroperation_test

修改提交代码
在本地文件里修改代码,比如在README.md中添加一句话。然后就可以提交了

git add .
git commit -m "xxx" //xxx:随便取名
git push

保持同步
对方也会上传自己修改的代码,我们需要和对方的repository保持同步。

在命令行终端进入本地仓库
cd git_coroperation_test

配置原仓库的路径:是对方的,不是自己的
git remote add upstream https://github.com/对方的/git_coroperation_test

查看远程目录的位置:能看到我们自己的和对方的远程目录位置
git remote -v

抓取原仓库的修改文件:
git fetch upstream

切换到master分支:一般我们应该是在master分支上,如果已经在了,会提示我们已经在master分支上的。
git checkout master

合并远程的master分支:
git merge upstream/master

git reset --soft HEAD^ //撤销 缓存区

你可能感兴趣的:(git开发遇到的常用用法)