@c-Ku
2018-05-25T10:16:06.000000Z
字数 2149
阅读 662
Git cNotes
右上角头像旁边 ➕下拉点击「New repository」创建新仓库
然后在需要上传的文件夹下打开终端 并依次输入以下指令
$ git init // 初始化$ git add . // 添加文件到暂存区$ git commit -m "rd-0.0.1" // 添加到仓库 双引内为版本号$ git remote add origin https://github.com/用户名/仓库名.git// 指定远程仓库$ git push -u origin master // 推到master分支上
fetch 命令进行合并
git fetch [<options>] [<repository> [<refspec>…]]git fetch [<options>] <group>git fetch --multiple [<options>] [(<repository> | <group>)…]git fetch --all [<options>]
比如 git fetch origin master 使用该命令 取回 origin 主机的 master 分支
所取回的更新,在本地主机上要用”远程主机名/分支名”的形式读取。比如origin主机的master分支,就可以用origin/master读取。
git branch命令的-r选项,可以用来查看远程分支,-a选项查看所有分支。
$ git branch -rorigin/master$ git branch -a* masterremotes/origin/master
最后需要在本地分支上通过以下命令合并本地的远程仓库
$ git merge origin/master# 或者$ git rebase origin/master
然后可以看到相对应的改变
$ git branch -a# 查看所有分支$ git checkout "分支名"# 切换到分支$ git checkout -b "分支名"# 新建并切换到分支$ git merge "分支名"# 合并临时分支$ git reflog# 獲取全部commit版本log$ git reset --hard "接需要回滾的版本號"$ git push --set-upstream origin test$ git branch -d test$ git push origin --delete test$ glg // 输出log$ git reset HEAD^ // 重设$ gcb reset-name
如何上手配置
➜ USER git config --global user.name "c-Ku"➜ USER git config --global user.email "chyhoosun@gmail.com"➜ USER ssh-keygen -t rsa -C "chyhoosun@gmail.com"Generating public/private rsa key pair.Enter file in which to save the key (/Users/6ml/.ssh/id_rsa):Created directory '/Users/6ml/.ssh'.Enter passphrase (empty for no passphrase):Enter same passphrase again:// 上面连着三个回车Your identification has been saved in /Users/6ml/.ssh/id_rsa.Your public key has been saved in /Users/6ml/.ssh/id_rsa.pub.The key fingerprint is:SHA256:DuNkVHwSyBJKRsmPaOsct8DWTgsXSOoiKXxLRHsFUbA chyhoosun@gmail.comThe key's randomart image is:+---[RSA 2048]----+| o+..*=+o. || +oo. +oo . ||o.+o.Eo o ||oo.+.o ||=.+ o = S ||=X B + + ||B @ + . . || o = || |+----[SHA256]-----+➜ USER eval "$(ssh-agent -s)"Agent pid 5982➜ USER ssh-add ~/.ssh/id_rsaIdentity added: /Users/6ml/.ssh/id_rsa (/Users/6ml/.ssh/id_rsa)➜ USER ssh -T git@github.comThe authenticity of host 'github.com (52.74.223.119)' can't be established.RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.Permission denied (publickey).
最后把 id_rsa.pub 里面的东西复制粘贴过去就好了