github使用 - Go语言中文社区

github使用


绑定

  1. 本地密钥并读取
    ssh-keygen -t rsa -C "邮箱"
    cd ~/.ssh
    cat id_rsa.pub
    然后回出现一些内容,从ssh开始一直复制到最后:
    在这里插入图片描述
  2. 绑定github账号,打开setting->SSH and GPG Key->New SSH key,输入复制的内容,标题随便
    在这里插入图片描述
  3. 验证,输入ssh -T git@github.com 会显示账号名

下载

git clone --recurse-submodules web下载全部分支

新建分支并上传文件

  1. 先用git clone 网址下载代码
  2. 做出修改后,使用git add name确定要添加的内容,name就是文件名or文件夹名
  3. 运行git commit -m 'balabala'添加描述信息
  4. 运行git branch -a可查看所有分支包括本地分支和远程分支,运行git branch -r查看远程分支,在这里运行git checkout -b branchname来新建个分支并切换到该分支,branchname就是自己定义的分支名
  5. 运行git push origin branchname就能将把刚才添加的内容送入新建的分支中

其他一些分支操作

  1. 切换分支git checkout branchname
  2. 删除分支git branch -d branch,注意只有不在当前分支才能删除这个分支

有git的情况,在clone的目录上点击右键,然后点击Git Bash Here,然后运行git add .,剩的上面一样

新建仓库并上传

  1. 执行ssh -T git@github.com

  2. 初始化 git init

  3. git add .

  4. git commit -m "xxx"

  5. git remote add origin 仓库地址

  6. git push -u origin master

从github更新到本地

git stash
git pull origin master

其他操作

git clone --recursive https://github.com/example/example.git
可以获得子模块

git pull origin master
可以获得更新,要在库文件夹里有.git的地方使用

删除文件

  1. git clone
  2. git init
  3. git rm FILEorgit rm -r name第一个是删除文件,第二个是删除文件夹

报错解决

  1. error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.
    运行:git config --global http.postBuffer 20000000 调整内存
  2. error: failed to push some refs to
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., ‘git pull …’) before pushing again.
    hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
    原因:remote上两个修改冲突了
    方法:使用git push -f origin master强行覆盖之前的

上传后github中的目录是黑色,无法打开,原因是该目录中有.git文件,所以要先删除.git文件,而在linux的文件夹中是看不到.git的,直接使用rm -rf .git来删除。
删除完了还是不可以,这是要删除原本的缓存,重新添加
git rm -r --cached re_add_name,re_add_name就是重新添加的文件夹的名字,删除完后重新git add .就行了,后面的操作都一样了
nothing to commit, working directory clean
这说明新加的东西没进入track列表

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/McEason/article/details/104303463
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢