github创建项目同步到本地

git

  • workspace:工作区
  • staging area:暂存区/缓存区
  • local repository:或本地仓库
  • remote repository:远程仓库
# 切到根目录下
cd ~
# 创建github目录用于存放各种github资源仓库
mkdir github
# 切到github目录下
cd github
# 本地创建资源仓库
mkdir The_beauty_of_programming
# 切到本地资源仓库目录
cd The_beauty_of_programming
# git初始化仓库
git init
# git 添加远程版本库
# 默认形式是 git remote add [shortname] [url] 其中shortname是本地资源库的名字
git remote add origin git@github.com:BOTAKKK/The-beauty-of-programming.git
# macbook下面iterm2现在默认是master分支 但是现在github上默认是main分支
# 切换到main分支
git checkout -b main
# 删除master分支(如果上面没有切换到main分支,然后做了下面的操作,会生成一个master分支,删除即可)
# git branch -d master
# git 拉取github上的资源到本地资源库
git pull origin main
# 创建/添加文件
touch text.txt
# 修改文件
open -e text.txt
# 添加文件到暂存区
git add . 
# 将暂存区内容添加到仓库中。
git commit -m "add text.txt"
# 将本地资源库push到相关联的github资源库中
git push origin main
posted @ 2020-12-03 20:24  BOTAK  阅读(123)  评论(0编辑  收藏  举报