git备忘录

git客户端安装

1.window Git-2.5.1-64 安装

2.设置Git的user name和email:(如果是第一次的话)

  git config --global user.name "humingx"

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

3、打开Gui Bash,执行生成公钥

  ssh-keygen -t rsa -C "[email protected]"

如果文件已经存在,则提示重新输入密码

4.在用户目录,如我的用户目录(C:\Users\xxx\.ssh),记事本打开id_rsa.pub,复制内容,黏贴在GitLab;

或者 cat ~/.ssh/id_rsa.pub  

5.测试是否设置成功:ssh -T [email protected] 

 

git命令

克隆:git clone [email protected]:project.git;

创建分支:git branch new_branch

列出可用分支:git branch

切换分支:git checkout new_branch

创建切换分支:git checkout -b test_branch

删除分支:git branch -D test_branch

重命名分支:git branch -m old_branch new_branch

推送:git push origin master

 

git config --global user.name "jack"
git config --global user.email "[email protected]"
Create a new repository
mkdir fromai_cn
cd fromai_cn
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:develper/xxx_cn.git
git push -u origin master
Push an existing Git repository
cd existing_git_repo
git remote add origin [email protected]:develper/xxx_cn.git
git push -u origin master

 

 

 

猜你喜欢

转载自zhongmin2012.iteye.com/blog/2315282