Git:命令行方式提交项目到指定分支
作者:互联网
1、找到要上传的项目的目录,右键打开命令行工具
2、新建一个本地分支,必须保证分支名称与远程的分支名称相同
zhai@DESKTOP-R14D2UH MINGW64 /d/github/git-test (dev) $ git branch dev-demo zhai@DESKTOP-R14D2UH MINGW64 /d/github/git-test (dev) $ git branch * dev dev-demo master
切换到新建的分支:
$ git checkout dev-demo Switched to branch 'dev-demo' zhai@DESKTOP-R14D2UH MINGW64 /d/github/git-test (dev-demo)
3、为远程地址创建别名
zhai@DESKTOP-R14D2UH MINGW64 /d/github/git-test (dev-demo) $ git remote add test https://gitee.com/zhai_huabing/git-test.git zhai@DESKTOP-R14D2UH MINGW64 /d/github/git-test (dev-demo) $ git remote -v my-picture https://gitee.com/zhai_huabing/my-picture.git (fetch) my-picture https://gitee.com/zhai_huabing/my-picture.git (push) origin https://gitee.com/zhai_huabing/jpa.git (fetch) origin https://gitee.com/zhai_huabing/jpa.git (push) test https://gitee.com/zhai_huabing/git-test.git (fetch) test https://gitee.com/zhai_huabing/git-test.git (push)
4、pull
zhai@DESKTOP-R14D2UH MINGW64 /d/github/git-test (dev-demo) $ git pull test dev-demo --allow-unrelated-histories From https://gitee.com/zhai_huabing/git-test * branch dev-demo -> FETCH_HEAD Merge made by the 'recursive' strategy. README.en.md | 36 ++++++++++++++++++++++++++++++++++++ README.md | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 README.en.md create mode 100644 README.md
5、init
zhai@DESKTOP-R14D2UH MINGW64 /d/github/git-test (dev-demo) $ git init Reinitialized existing Git repository in D:/github/git-test/.git/
6、add
zhai@DESKTOP-R14D2UH MINGW64 /d/github/git-test (dev-demo) $ git add .
7、commit
git commit -m "init"
8、push
zhai@DESKTOP-R14D2UH MINGW64 /d/github/git-test (dev-demo) $ git push test dev-demo Enumerating objects: 212, done. Counting objects: 100% (212/212), done. Delta compression using up to 4 threads Compressing objects: 100% (138/138), done. Writing objects: 100% (211/211), 53.84 KiB | 950.00 KiB/s, done. Total 211 (delta 37), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (37/37), done. remote: Powered by GITEE.COM [GNK-6.2] To https://gitee.com/zhai_huabing/git-test.git 4395983..5020a55 dev-demo -> dev-demo
标签:git,命令行,demo,dev,github,Git,zhai,提交,test 来源: https://www.cnblogs.com/zhai1997/p/15704130.html