git 相关知识

1、更改remote从https改为ssh

#查看git的状态
git remote -v

#origin https://github.com/qingjian1991/Manec (fetch)
#origin https://github.com/qingjian1991/Manec (push)
#更改git的属性
git remote set-url origin git@github.com:qingjian1991/Manec.git
git remote -v

#origin git@github.com:qingjian1991/Manec.git (fetch)
#origin git@github.com:qingjian1991/Manec.git (push)

git remote的管理

2、创建新的仓库并且上传文件
在GitHub上创建新的仓库,并且不要添加README, .gitignore or License file等文件

# create a new directory, and initialize it with git-specific functions
git init my-repo

# change into the `my-repo` directory
cd my-repo

# create the first file in the project
touch README.md

# git isn't aware of the file, stage it
git add README.md

# take a snapshot of the staging area
git commit -m "add README to initial commit"

# provide the path for the repository you created on github
git remote add origin https://github.com/YOUR-USERNAME/YOUR-REPOSITORY-NAME.git

# push changes to github
git push --set-upstream origin main

3、从远处仓库拉取文件并比较本地的差异

git pull origin main
#From github.com:qingjian1991/Jerry
#* branch            main       -> FETCH_HEAD
#Already up-to-date.

https://docs.github.com/en/get-started/using-git/about-git

https://backlog.com/git-tutorial/tw/stepup/stepup2_4.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、搭建私有Git服务器 1.1 服务器搭建 远程仓库实际上和本地仓库没啥不同,纯粹为了7x24小时开机并交换...
    小陈工阅读 1,742评论 2 3
  • 一、使用git管理文件版本 1.1修改文件 1.1.1提交修改 被版本库管理的文件不可避免的要发生修改,此时只...
    小陈工阅读 1,111评论 0 1
  • 一. shell shell是什么?壳?其实就是操作系统包含一个外壳,然后让用户通过这个壳来操作OS,而shell...
    扛支枪阅读 7,668评论 0 2
  • window 安装git 配置邮箱和用户名 git config --global user.name"Your ...
    program_sheep阅读 890评论 0 0
  • 我比较笨,喜欢简单粗暴的。总体来说就是干三件事: 建立本地仓库,建立github仓库 建立本地仓库与github网...
    yuanthu阅读 5,163评论 0 0