一、拉取代码
在本地新建一个文件夹,对于windows系统,需要下载并安装git,在文件夹下右键—打开Git Bash Here;对于linux系统,直接在文件夹下打开终端即可。
1. git init
2. 设置SSH
3. git remote add origin git@xxxxx # Clone with SSH
4. git pull origin master # 将远程主机最新内容拉到本地并合并到本地分支
或 git fetch origin master # 不合并
配置SSH方法详见 SSH配置
二、上传代码
1. git init
2. git config --global user.email" " # 填写相应的email
3. git config --global user.name " " # 填写相应的用户名
4. git add .
5. git commit -m " " # 双引号内可填写备注
6. git pull git@xxxxx master --allow-unrelated-histories # git@xxxxx—Clone with SSH
7. git remote add origin git@xxxxx # Clone with SSH
8. git push -u origin master # 此master为分支名称,可根据实际情况更改此名称
三、上传更新代码
1. git status # 查看代码是否有更新
2. git add .
3. git commit -m " " # 双引号内可填写备注——只会提交添加到缓存区的文件到本地仓库
或 git commit -a -m " " # 能提交修改过但没有添加到缓存区的文件
4. git push master