git查看本地和建立分支、上傳分支、提交代碼到分支、刪除分支等,git分支

來源:互聯網
上載者:User

git查看本地和建立分支、上傳分支、提交代碼到分支、刪除分支等,git分支
git查看本地和建立分支以及上傳分支到伺服器

以下是git命令列裡邊的命令操作,加上了說明:

Welcome to Git (version 1.9.5-preview20141217)Run 'git help git' to display the help index.Run 'git help <command>' to display help for specific commands.##進入項目目錄下giscafer@LAOHOUBIN-PC /G/002_project$ cd Comments##查看遠程分支有哪些giscafer@LAOHOUBIN-PC /G/002_project/Comments (master)$ git branch -a  doc* master  remotes/origin/HEAD -> origin/master  remotes/origin/doc  remotes/origin/master##查看本地分支有哪些giscafer@LAOHOUBIN-PC /G/002_project/Comments (master)$ git branch  doc* master##建立本地test分支giscafer@LAOHOUBIN-PC /G/002_project/Comments (master)$ git branch test##查看本地分支即可見到多了test分支giscafer@LAOHOUBIN-PC /G/002_project/Comments (master)$ git branch  doc* master  test##將本地test分支推送到遠程伺服器giscafer@LAOHOUBIN-PC /G/002_project/Comments (master)$ git push origin testUsername for 'https://git.oschina.net': giscaferPassword for 'https://giscafer@git.oschina.net':Total 0 (delta 0), reused 0 (delta 0)To https://git.oschina.net/giscafer/Comments.git * [new branch]      test -> test##切換到test分支giscafer@LAOHOUBIN-PC /G/002_project/Comments (master)$ git checkout testSwitched to branch 'test'##添加本地需要上傳的檔案夾(代碼檔案添加方式 git add 檔案.js)giscafer@LAOHOUBIN-PC /G/002_project/Comments (test)$ git add db##提交資訊giscafer@LAOHOUBIN-PC /G/002_project/Comments (test)$ git commit -m '提交資料結構表設計文檔到test分支上'[test 867e877] 提交資料結構表設計文檔到test分支上 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "db/\346\225\260\346\215\256\345\272\223\350\241\250\347\273\223\346\236\204.docx"Warning: Your console font probably doesn't support Unicode. If you experience strange characters in the output, consider switching to a TrueType font such as Lucida Console!##上傳到遠程伺服器下邊是報錯資訊(因為提交到分支需要給出--set-upstream origin <分支名>)giscafer@LAOHOUBIN-PC /G/002_project/Comments (test)$ git pushfatal: The current branch test has no upstream branch.To push the current branch and set the remote as upstream, use    git push --set-upstream origin test##如下將提交推送到遠程伺服器giscafer@LAOHOUBIN-PC /G/002_project/Comments (test)$ git push --set-upstream origin testUsername for 'https://git.oschina.net': giscaferPassword for 'https://giscafer@git.oschina.net':Counting objects: 6, done.Delta compression using up to 8 threads.Compressing objects: 100% (4/4), done.Writing objects: 100% (4/4), 14.90 KiB | 0 bytes/s, done.Total 4 (delta 1), reused 0 (delta 0)To https://git.oschina.net/giscafer/Comments.git   a7e5547..867e877  test -> testBranch test set up to track remote branch test from origin.
##刪除本地分支(提示錯誤是因為當初使用這test分支)    giscafer@LAOHOUBIN-PC /G/002_project/Comments (test)$ git branch -d testerror: Cannot delete the branch 'test' which you are currently on.##切換到其他分支giscafer@LAOHOUBIN-PC /G/002_project/Comments (test)$ git checkout docSwitched to branch 'doc'Your branch is up-to-date with 'origin/doc'.##再次刪除即可giscafer@LAOHOUBIN-PC /G/002_project/Comments (doc)$ git branch -d testwarning: deleting branch 'test' that has been merged to         'refs/remotes/origin/test', but not yet merged to HEAD.Deleted branch test (was 867e877).giscafer@LAOHOUBIN-PC /G/002_project/Comments (doc)$ git branch* doc  master
##查看當前的origin$ git remote -vorigin  https://git.oschina.net/giscafer/Comments.git (fetch)origin  https://git.oschina.net/giscafer/Comments.git (push)
##刪除遠端分支giscafer@LAOHOUBIN-PC /G/002_project/Comments (doc)$ git push origin :testUsername for 'https://git.oschina.net': giscaferPassword for 'https://giscafer@git.oschina.net':To https://git.oschina.net/giscafer/Comments.git - [deleted]         test

END

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.