Git:命令列方式提交專案到指定分支
阿新 • • 發佈:2021-12-17
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每個人都會有一段異常艱難的時光 。 生活的壓力 , 工作的失意 , 學業的壓力。 愛的惶惶不可終日。 挺過來的 ,人生就會豁然開朗。 挺不過來的 ,時間也會教你 ,怎麼與它們握手言和 ,所以不必害怕的。 ——楊絳