开源中国git,13661892653/jk**ac,https://gitee.com/profile/sshkeys
1、初始化git目录,新建目录test
chenlun@kf-0531 MINGW32 /e/project/test
$ git init
Initialized empty Git repository in E:/project/test/.git/
2、创建一个文件提交到远程,任意名字
$ git add .
3、提交commit代码
$ git commit -m 'message'
[master (root-commit) 2807ce1] message
1 file changed, 93 insertions(+)
create mode 100644 "\346\227\245\345\270\270\350\256\260\345\275\225.xml"
4、在线创建test项目
5、本地push之前先记得pull
$ git pull origin master
6、添加到远程仓库
chenlun@kf-0531 MINGW32 /e/project/test (master)
$ git remote add origin https://gitee.com/detach001/test.git
7、push代码到远程仓库
git push -u origin master
git分支操作
首先,我们创建dev分支,然后切换到dev分支:
$ git checkout -b dev
Switched to a new branch 'dev'
然后,用git branch命令查看当前分支:
$ git branch
* dev
master
先add再提交修改
$ git add .
$ git commit -m "xxx"
[dev c2621c4] xxx
1 file changed, 39 insertions(+)
create mode 100644 "README - \345\211\257\346\234\254.md"
现在,dev分支的工作完成,我们就可以切换回master分支:
chenlun@kf-0531 MINGW32 /e/project/test (dev)
$ git checkout master
Switched to branch 'master'
现在,我们把dev分支的工作成果合并到master分支上:
$ git merge dev
Updating c7154ad..c2621c4
Fast-forward
"README - \345\211\257\346\234\254.md" | 39 ++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 "README - \345\211\257\346\234\254.md"
最后合并到master
$ git push -u origin master
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 243 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
remote: Powered by Gitee.com
To https://gitee.com/detach001/test.git
c7154ad..c2621c4 master -> master
Branch master set up to track remote branch master from origin.