发表于: 2022-11-22 21:47:40

0 695


1.git与github的交互

  • 管理远程存储库

a.创建远程储存库:

$ git remote add origin https://github.com/USER/REPO>.git  # Set a new remote 

 $ git remote -v # Verify new remote 

> origin  https://github.com/USER/REPO.git (fetch)

 > origin  https://github.com/USER/REPO.git (push)


b.重命名远程库

$ git remote -v # View existing remotes 

> origin  https://github.com/OWNER/REPOSITORY.git (fetch)

 > origin  https://github.com/OWNER/REPOSITORY.git (push) 

 $ git remote rename origin destination    

 # Change remote name from 'origin' to 'destination' 

 $ git remote -v     

 # Verify remote's new name 

> destination  https://github.com/OWNER/REPOSITORY.git (fetch)

 > destination  https://github.com/OWNER/REPOSITORY.git (push)


c.删除远程库(注意:git remote rm不会从服务器中删除远程存储库。它只是从本地存储库中删除远程及其引用。)

$ git remote -v # View current remotes 

 > destination  https://github.com/FORKER/REPOSITORY.git (fetch) 

> destination  https://github.com/FORKER/REPOSITORY.git (push)

 $ git remote rm destination # Remove remote 


d.使用命令将远程 URL 从 SSH 更改为 HTTPS git remote set-url。

$ git remote set-url origin https://github.com/USERNAME/REPOSITORY.git


e.使用命令将远程 URL 从 HTTPS 更改为 SSH git remote set-url。

$ git remote set-url origin git@github.com:USERNAME/REPOSITORY.git


  • 使用 HTTPS URL 克隆(详情见链接)

https://blog.csdn.net/ljk126wy/article/details/88767555

登录我们的github 复制我们的github 项目的https 地址。

、在我们的本地磁盘下创建文件夹用来保存我们的远程git项目。

、通过git clone 远程仓库地址 克隆我们远程仓库的项目



  • 使用 GitHub CLI 克隆(详情见链接)

https://blog.csdn.net/PursueLuo/article/details/109544993

这里面有很详细的图文讲解包括github cli的下载链接、配置、使用。


  • 创建库

a.在github上创建,和昨天学习的《github introduce》课程有重合

https://docs.github.com/en/get-started/quickstart/create-a-repo?tool=webui

b.用github cli 创建

输入gh repo create命令,按照提示往下走。

 What would you like to do? Create a new repository on GitHub from scratch

? Repository name studygit

? Repository name studygit

? Description

? Description

? Visibility Private

? Would you like to add a README file? Yes

? Would you like to add a .gitignore? Yes

? Choose a .gitignore template #这个不知道怎么选,瞎选的,这个坑以后再填

? Would you like to add a license? No

? This will create "studygit" as a private repository on GitHub. Continue? Yes #github

✓ Created repository NancyFeng88/studygit on GitHub

? Clone the new repository locally? Yes  #本地


目前认为github cli 更好用,可以同时在github和本地同时建库

  • 提交第一个更改

  1. 在命令行中,导航到新项目的根目录。(此目录是在您运行gh repo create命令时创建的。)

    /创建一个README文件,其中包含有关该项目的一些信息。

    echo "info about this project" >> README.md

    /输入git status。您会看到您有一个未跟踪的README.md文件。

    $ git status Untracked files:  (use "git add..." to include in what will be committed)  README.md nothing added to commit but untracked files present (use "git add" to track)

    /暂存并提交文件。

    git add README.md && git commit -m "Add README"

    /将更改推送到您的分支。

    git push --set-upstream origin HEAD

2.解决git bash中无法粘贴的问题

https://blog.csdn.net/wsad0zxcvbnm/article/details/116720894

不得不说CSDN真是个宝藏库,解决了我不少问题。


3.明天继续:

学习github文档,掌握github使用知识;继续编写城市天际线项目。





返回列表 返回列表
评论

    分享到