macos(4)之git本地项目初始化并提交远程仓库

1、先在远程仓库(如github)创建项目,为了避免错误,不要初始化 README, license, 或者gitignore文件 .

2、打开Terminal终端

3、切换到你的本地项目目录

4、初始化本地仓库

git init

5、添加文件到本地仓库

git add .

# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.

6、提交文件

git commit -m "First commit"

# Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.

7、到远程仓库的页面上,复制仓库地址 (笔者以配置好ssh,故复制ssh形式的仓库地址)

8、添加远程仓库地址到本地仓库

git remote add origin {远程仓库地址}

# Sets the new remote

git remote -v

# Verifies the new remote URL

9、push到远程仓库

git push -u origin master

# Pushes the changes in your local repository up to the remote repository you

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

推荐阅读更多精彩内容

  • Git 基础 基本原理 客户端并不是只提取最新版本的文件快照,而是把代码仓库完整的镜像下来。这样一来,任何一处协同...
    __silhouette阅读 15,948评论 5 147
  • Lesson 3: Using GitHub to Collaborate 3.1 Creating a GitH...
    赤乐君阅读 6,142评论 3 11
  • Git 命令行学习笔记 Git 基础 基本原理 客户端并不是只提取最新版本的文件快照,而是把代码仓库完整的镜像下来...
    sunnyghx阅读 3,952评论 0 11
  • 长跑校队的故事 “我不能放弃。” 我在心里跟自己说,希望自己不要被脑海中想要退出的想法所打败。 一开始我就知道参加...
    童与阅读 603评论 0 2
  • 他是黑人,1963年2月17日出生于纽约布鲁克林贫民区。他有两个哥哥,一个姐姐,一个妹妹,父亲微薄的工资根...
    松間明月阅读 648评论 0 1