关闭

git命令行提交代码到远程仓库

标签: git代码同步git入门新建项目同步CSDNgit命令行
197人阅读 评论(0) 收藏 举报
分类:
1.本地建立一个gitdemo的java项目。然后cmd到该项目下面初始化本地仓库

➜  gitdemo git:(master) git init
Initialized empty Git repository in /Users/xxxx/Documents/workspace/gitdemo/.git/

2.关联远程CSDN仓库(此处设置为https的地址,不需要shh的私钥匙和公钥)

➜  gitdemo git:(master) git remote add origin https://code.csdn.net/csdn_xxxxx/gitdemo.git

可以通过命令查看设置的git的值

➜  gitdemo git:(master) git config --list
user.name=csdn_xxxxx
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://code.csdn.net/csdn_xxxxx/gitdemo.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

3.提交文件

➜  gitdemo git:(master) git add src/com/cy/Demo.java
➜  gitdemo git:(master) git add src/com/cy/Demo2.java

4.提交完毕commit到私有库

➜  gitdemo git:(master) git commit -m "first commit"                                      
[master (root-commit) 76179f3] first commit
 2 files changed, 12 insertions(+)
 create mode 100644 src/com/cy/Demo.java
 create mode 100644 src/com/cy/Demo2.java

5.push到CSDN库

➜  gitdemo git:(master) git push -u origin master                                         
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (7/7), 486 bytes | 0 bytes/s, done.
Total 7 (delta 0), reused 0 (delta 0)
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

6.通过命令查看git私有库的状态

➜  gitdemo git:(master) git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

.classpath
.project
.settings/
bin/

nothing added to commit but untracked files present (use "git add" to track)
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1058次
    • 积分:59
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档