git管理代码使⽤⽅法常见问题解决⽅案如下图:
图⼀:
图⼆:
图三:
图四:
s 上⾯的图⽚好像需要⼀个key? 那么问题就就来了,key 怎么获取呢
下⾯我讲⼀⼀介绍
在图三中,
《点击上⾯图⽚ 上的  add an SSH key 》,会进⼊到⼀个页⾯,此页⾯是 添加SSH key 的说明,不过是英⽂的,⾃⼰可以去百度翻译下,中⽂的可以⾃⼰去看其他的博客
我们可以通过命令⾏来⽣成SSH key
administrator:~ administrator$ cd ~/.ssh
cd ~/.ssh
git常用指令-bash: cd: /Users/administrator/.ssh: No such file or directory
config  id_rsa  id_rsa.pub  known_hosts
administrator:~ administrator$ config  id_rsa  id_rsa.pub  known_hosts
-bash: config: command not found
ssh-keygen -t rsa -C "添加⾃⼰的邮箱"
administrator:~ administrator$ ssh-keygen -t rsa -C "添加⾃⼰的邮箱"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/administrator/.ssh/id_rsa):
Created directory '/Users/administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/administrator/.ssh/id_rsa.
Your public key has been saved in /Users/administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:IdZ/tJj2Sf/vVcEaABT268Clacr58pxEx0oQs+**********************
The key's randomart image is:
+---[RSA 2048]----+
|      +.=o.    |
|      ..B . . .  |
|      oEo+ o.. o |
|    ...Bo=+..o .|
|      .SO=++.  .|
|      . *.=+ o  .|
|      + o .o . .|
|      .+ .    ..|
|        o=    .=|
+----[SHA256]-----+
pbcopy < ~/.ssh/id_rsa.pub
administrator:~ administrator$ pbcopy < ~/.ssh/id_rsa.pub
git add .
administrator:~ administrator$ git add .
fatal: Not a git repository (or any of the parent directories): .git
administrator:~ administrator$ git config --global user.name "mjq"
git config --global user.name "mjq"
administrator:~ administrator$
最后得到了两个⽂件:id_rsa和id_rsa.pub:在此⽬录下,⾃⼰可以搜到到,下⾯会⽤到的哦
Your identification has been saved in /Users/administrator/.ssh/id_rsa.
Your public key has been saved in /Users/administrator/.ssh/id_rsa.pub.
然后⾃⼰去上⾯图⽚显⽰的页⾯ 去 添加 SSH key
保存以后,再次刷新 第⼆个页⾯时,没有出现
you won't be able to push project code via SSH until you add an SSH key to you profilesh
说明ssh key 已经添加好了(当然,有些git 不添加也可以去使⽤,当你的git 服务器没有使⽤SSH ,使⽤的是http时候,就不需要配置ssh)-------------------------------------------------------
上⾯的事情就可以告⼀段落了,如果这样就认为这是⼀个和谐社会,那你就想多了
不是说好的 git 管理代码的使⽤说明,好像什么都没有说呀
哈哈哈......
我们继续
下⾯将隆重介绍 git 的使⽤⽅法 及其 常见问题的解决⽅案:
********************** 功能:上传项⽬到 git **********************
前提: 把项⽬⾥⾯ ⾃带的git ⽂件删除,如果不删除,输⼊命令git init 时,
会显⽰Reinitialized existing Git repository in.. ..
再输⼊ git status 时,
On branch masternothing to commit, working directory clean(翻译:⽆提交,⼯作⽬录清洁)
当你把项⽬修改过,执⾏第⼀步中的  cd /Users/administrator/Desktop/BYM3.4  、第⼆步git status ,后此时会出现On branch masterChanges to be committed:  (use "git " to unstage)modified:  deproj/project.pbxprojnew file: asd/dd.hnew file:  asd/dd.m(这些⽂件是你修改的⽂件,不⽤管它)执⾏第三步就好,然后,继续执⾏就可以了
第⼀步:
administrator:~ administrator$ cd /Users/administrator/Desktop/BYM3.4
administrator:BYM3.4 administrator$ git init
Initialized empty Git repository in /Users/administrator/Desktop/BYM3.4/.git/
第⼆步:
administrator:BYM3.4 administrator$git status
On branch masterInitial commitUntracked files:  (use "" to include in what will be committed)
WGZY/
WGZYTests/
nothing added to commit but untracked files present (use "git add" to track)
第三步:
administrator:BYM3.4 administrator$ git add .
第四步:
administrator:BYM3.4 administrator$git commit -m "first commit"
[master (root-commit) c016112] first commit
1737 files changed, 111203 insertions(+)
create mode deproj/project.pbxproj
create mode workspacedata
create mode workspace/heckout
….(省略很多)
create mode 100755 WGZYTests/Info.plist
create mode 100755 WGZYTests/WGZYTests.m
第五步:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。