赞
踩
首先,需要建立一个git服务器-----
这里介绍如何使用git这个服务器
我们在github上下载一份代码,里面有如下内容
我们使用git服务器的时候不能有.git 文件,所以在此将其删除
ys-linux@ubuntu:~/Documents/pc_simulator$ rm -rf .git
ys-linux@ubuntu:~/Documents/pc_simulator$ rm -rf .gitmodules
然后屏蔽上传编译文件
ys-linux@ubuntu:~/Documents/pc_simulator$ cat .gitignore
然后创建一个git
登陆服务器创建一个账户
创建一个项目,名称叫kcsdr_ui
然后在终端输入
ys-linux@ubuntu:~/Documents/pc_simulator$ git init
Initialized empty Git repositoryin /home/ys-linux/Documents/pc_simulator/.git/ys-linux@ubuntu:~/Documents/pc_simulator$ git remote add origin http://192.168.11.222/ys/kcsdr_ui.git
ys-linux@ubuntu:~/Documents/pc_simulator$ git remote -v
origin http://192.168.11.222/ys/kcsdr_ui.git (fetch)
origin http://192.168.11.222/ys/kcsdr_ui.git (push)
ys-linux@ubuntu:~/Documents/pc_simulator$ git status
On branch master
Initial commit
Untracked files:
(use "git add ..." to include in what will be committed)
.cproject
.gitignore
.project
Makefile
README.md
fontAndImg/
gui/
licence.txt
lv_conf.h
lv_drivers/
lv_drv_conf.h
lv_ex_conf.h
lv_examples/
lvgl/
main.c
misc_conf.h
nothing added to commit but untracked files present (use "git add" to track)
现在库创建好了,然后增加内容
ys-linux@ubuntu:~/Documents/pc_simulator$ git add .
ys-linux@ubuntu:~/Documents/pc_simulator$ git status
On branch master
Initial commit
Changes to be committed:
(use"git rm --cached ..."to unstage)newfile: .cprojectnewfile: .gitignorenewfile: .project
.......................................................
然后填写更新内容
ys-linux@ubuntu:~/Documents/pc_simulator$ git commit -m ""
***Please tell me who you are.
Run
git config--global user.email "you@example.com"git config--global user.name "Your Name"toset your account's default identity.
Omit --global to set the identity only in thisrepository.
fatal: unable to auto-detect email address (got 'ys-linux@ubuntu.(none)')
ys-linux@ubuntu:~/Documents/pc_simulator$ git config --global user.email "ys@qq.com"ys-linux@ubuntu:~/Documents/pc_simulator$ git config --global user.name "ys"ys-linux@ubuntu:~/Documents/pc_simulator$ git commit -m ""[master (root-commit) 12d5763]
438 files changed, 834218 insertions(+)
create mode100755.cproject
create mode100755.gitignor
.............................................................
然后将代码上传
ys-linux@ubuntu:~/Documents/pc_simulator$ git status
On branch master
nothing to commit, working directory clean
ys-linux@ubuntu:~/Documents/pc_simulator$ git log
commit 12d57637f6243951d888fa2
Author: ysDate: Wed May9 21:28:27 2018 -0700
ys-linux@ubuntu:~/Documents/pc_simulator$ git push
warning: push.default is unset; its implicit value has changed inGit2.0 from 'matching' to 'simple'. To squelch thismessage
and maintain the traditional behavior, use:
git config--global push.defaultmatching
To squelchthis message and adopt the newbehavior now, use:
git config--global push.defaultsimple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git2.0, Git defaults to the more conservative 'simple'behavior, which only pushes the current branch to the corresponding
remote branch that'git pull'uses to update the current branch.
See'git help config' and search for 'push.default' forfurther information.
(the'simple' mode was introduced in Git 1.7.11. Use the similar mode'current' instead of 'simple' ifyou sometimes use older versions of Git)
fatal: The current branch master has no upstream branch.
To push the current branch andset the remote asupstream, use
git push--set-upstream origin master
ys-linux@ubuntu:~/Documents/pc_simulator$ git push --set-upstream origin master
Usernamefor 'http://192.168.11.222': ys
Passwordfor 'http://ys@192.168.11.222': *********
...............................
获取根密钥
ys-linux@ubuntu:~/Documents/pc_simulator$ ssh-keygen
ys-linux@ubuntu:~/Documents/pc_simulator$ cat ~/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAo59EMzaF8H3p8u/Ad21xm9kAHatj82Dt5G2Cl0teDibTX/IP
THAynvHKCVX+khgBJuXaAAc1rij***********8y67ZvPfMqKb9YeURw69c
lnudgUmnvWuwqnTvptwsnsI9DdddILAaTr6zWMzu7jiX1Xr67pqUbaq3utAKb8v/
d1/frf4FZu1jAY3K1ST7fsj/f6rTOLm3Z/iM8SZoOuvYBnhsFjy2LC3E0NHzpN+S
wt7HssG9BAYSjSOlLYUEy+EocF**************b96ErNtiNezgzeKsBXk49CmQ
Qoa16Rg6pxs1GhQmdJ8YPzBQLoGRz+M8jrzI2wIDAQABAoIBAGCmW2rE8ik0t1TB
An7g/z2fU31HyGBQq6hqS8oxyjJt1ngVUcb3bWutF12X16DXFDYYV1aSa7oW7iIJ
ZkpuPwKBgQDK*****************************x2ZuuprQBHaiOCdWCT0gHA9
2qr4HRvJF5RTSv/ukct2azlpPvdq0Au5WX/t+N9KjBx7IE9AkXi1K6RtvflsUui8
cIuohVQGC54FxrHda6SU22XEcPcueyoq5Pzs55qdVi9VHAe0ziTRoQ==
-----END RSA PRIVATE KEY-----
将获取的根密钥贴在git网站上
贴上网站后
ys-linux@ubuntu:~/Documents/pc_simulator$ cat ~/.ssh/id_rsa.pub
ys-linux@ubuntu:~/Documents/pc_simulator$ git config --global push.default simple
ys-linux@ubuntu:~/Documents/pc_simulator$ git remote remove origin
ys-linux@ubuntu:~/Documents/pc_simulator$ git remote -v
ys-linux@ubuntu:~/Documents/pc_simulator$ git remote add origin git@192.168.11.222:ys/kcsdr_ui.git -----这里写你上传的本地服务器的地址
ys-linux@ubuntu:~/Documents/pc_simulator$ git remote -v
然后可以正常使用git了
更新代码
git add .
更新提示信息
git commit -m ""
抓取已经存在的代码
git pull
上传本地的代码
git push
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。