1、本地新建文件提交到git服务器
1.1、初始化本地git裆裤:
$ git init
1.2、关联git服务器:
$git remote add origin https://10.10.1.183:8443/relationrules/unicom/rules.git
1.3、将当前目录下的所有文件提交到本地git:
$ git add -A
1.4、提交注释:
$ git commit -m "提交***"
1.5、将本地git的内容push到git服务器上
$ git push origin master:master(第一个master是本地分支名称,第二个master是要提交到远程分支的名)
2、如果push文件时报错如下,则表示本地和服务器版本不一致,从服务器上取最新的版本覆盖到本地:
$ git push origin master:master
Username for 'https://10.10.1.183:8443': xukaixun
To https://10.10.1.183:8443/relationrules/unicom/rules.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://10.10.1.183:8443/relationrules/unicom/rules.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
如果出现以上报错,则执行下面命令:
$ git pull origin master --allow-unrelated-histories
Username for 'https://10.10.1.183:8443': xukaixun
From https://10.10.1.183:8443/relationrules/unicom/rules
* branch master -> FETCH_HEAD
Merge made by the 'recursive' strategy.
README.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 README.md
再次提交,就会成功:
$ git push origin master:master
Username for 'https://10.10.1.183:8443': xukaixun
Counting objects: 2086, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2079/2079), done.
Writing objects: 100% (2086/2086), 983.92 KiB | 373.00 KiB/s, done.
Total 2086 (delta 1850), reused 0 (delta 0)
remote: Resolving deltas: 100% (1850/1850), done.
To https://10.10.1.183:8443/relationrules/unicom/rules.git
254d4c4..42766d0 master -> master
3、查看本地git的版本:
$ git branch
* master
4、下载git服务器文件到本地
4.1、初始化本地git裆裤:
$ git init
4.2、关联git服务器:
$git remote add origin https://10.10.1.183:8443/relationrules/unicom/rules.git
4.3、从git服务器上讲文件pull到本地:
$ git pull origin feature-NR17001202:master
Username for 'https://10.10.1.183:8443': xukaixun
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 1), reused 9 (delta 1)
Unpacking objects: 100% (9/9), done.
From https://10.10.1.183:8443/relationrules/mobile/rules
* [new branch] feature-NR17001202 -> master
* [new branch] feature-NR17001202 -> origin/feature-NR17001202
5、git下载代码到当前目录:
git clone -b release-v3.0.1.0 https://10.10.1.183:8443/ueca/gaia3.0.git
6、解决git每次pull或者push操作时都需要输入密码:
git bash命令行进入到项目的目录,输入下面命令:
git config --global credential.helper store
然后你会在你本地生成一个文本,上边记录你的账号和密码。当然这些你可以不用关心。
然后你使用上述的命令配置好之后,再操作一次git pull,然后它会提示你输入账号密码,这一次之后就不需要再次输入密码了。