git 資料搜尋

來源:互聯網
上載者:User
文章目錄
  • 有用url:
  • 下載submodel 代碼:
  • Creating a Remote Branch
  • Cleaning up Mistakes
  • Use the Branch from Another Location
  • Automate it A Bit
有用url:

http://rogerdudler.github.io/git-guide/index.zh.html

設定代理Xml代碼  
  1. git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:port  

刪除代理Xml代碼  

  1. git config --system (or --global or --local) --unset http.proxy  

關閉SSL驗證Xml代碼  

  1. git config --global http.sslVerify false  

下載代碼Xml代碼  

  1. git clone http://server.com/source.git 

下載submodel 代碼:

git pull https://ybkoprm01.corp.ybusa.net/git/hapiclient-android.git
Creating a Remote Branch

1. Create the remote branch

git push origin origin:refs/heads/new_feature_name

2. Make sure everything is up-to-date

git fetch origin

3. Then you can see that the branch is created.

git branch -r

This should show ‘origin/new_feature_name’

4. Start tracking the new branch

git checkout --track -b new_feature_name origin/new_feature_name

This means that when you do pulls that it will get the latest from that branch as well.

5. Make sure everything is up-to-date

git pull
Cleaning up Mistakes

If you make a mistake you can always delete the remote branch

git push origin :heads/new_feature_name

(Ok Git’ers – that has to be the least intuitive command ever.)

Use the Branch from Another Location

When you get to another computer or clone the git repository to a new computer, then you just need to start tracking the new branch again.

git branch -r

to show all the remote branches

git checkout --track -b new_branch origin/new_feature_name

to start tracking the new branch

Automate it A Bit

That’s a pretty easy thing to automate with a small shell script luckily

#!/bin/sh# git-create-branch <branch_name> if [ $# -ne 1 ]; then         echo 1>&2 Usage: $0 branch_name         exit 127fi set branch_name = $1git push origin origin:refs/heads/${branch_name}git fetch origingit checkout --track -b ${branch_name} origin/${branch_name}git pullGit常用操作命令收集:1) 遠程倉庫相關命令檢出倉庫:$ git clone git://github.com/jquery/jquery.git查看遠程倉庫:$ git remote -v添加遠程倉庫:$ git remote add [name] [url]刪除遠程倉庫:$ git remote rm [name]修改遠程倉庫:$ git remote set-url --push[name][newUrl]拉取遠程倉庫:$ git pull [remoteName] [localBranchName]推送遠程倉庫:$ git push [remoteName] [localBranchName]2)分支(branch)操作相關命令查看本地分支:$ git branch查看遠程分支:$ git branch -r建立本地分支:$ git branch [name] ----注意新分支建立後不會自動切換為當前分支切換分支:$ git checkout [name]建立新分支並立即切換到新分支:$ git checkout -b [name]刪除分支:$ git branch -d [name] ---- -d選項只能刪除已經參與了合并的分支,對於未有合并的分支是無法刪除的。如果想強制移除一個分支,可以使用-D選項合并分支:$ git merge [name] ----將名稱為[name]的分支與當前分支合并建立遠程分支(本地分支push到遠程):$ git push origin [name]刪除遠程分支:$ git push origin :heads/[name]

我從master分支建立了一個issue5560分支,做了一些修改後,使用git push origin master提交,但是顯示的結果卻是'Everything up-to-date',發生問題的原因是git push origin master 在沒有track遠程分支的本地分支中預設提交的master分支,因為master分支預設指向了origin master 分支,這裡要使用git push origin issue5560:master 就可以把issue5560推送到遠端master分支了。

    如果想把本地的某個分支test提交到遠程倉庫,並作為遠程倉庫的master分支,或者作為另外一個名叫test的分支,那麼可以這麼做。$ git push origin test:master         // 提交本地test分支作為遠端master分支$ git push origin test:test              // 提交本地test分支作為遠端test分支如果想刪除遠端分支呢?類似於上面,如果:左邊的分支為空白,那麼將刪除:右邊的遠端分支。$ git push origin :test              // 剛提交到遠端test將被刪除,但是本地還會儲存的,不用擔心3)版本(tag)操作相關命令查看版本:$ git tag建立版本:$ git tag [name]刪除版本:$ git tag -d [name]查看遠程版本:$ git tag -r建立遠程版本(本地版本push到遠程):$ git push origin [name]刪除遠程版本:$ git push origin :refs/tags/[name]4) 子模組(submodule)相關操作命令添加子模組:$ git submodule add [url] [path]如:$ git submodule add git://github.com/soberh/ui-libs.git src/main/webapp/ui-libs初始化子模組:$ git submodule init ----只在首次檢出倉庫時運行一次就行更新子模組:$ git submodule update ----每次更新或切換分支後都需要運行一下刪除子模組:(分4步走哦)1)$ git rm --cached [path] 2) 編輯“.gitmodules”檔案,將子模組的相關配置節點刪除掉3) 編輯“.git/config”檔案,將子模組的相關配置節點刪除掉4) 手動刪除子模組殘留的目錄 5)忽略一些檔案、檔案夾不提交在倉庫根目錄下建立名稱為“.gitignore”的檔案,寫入不需要的檔案夾名或檔案,每個元素佔一行即可,如targetbin*.dbGit 是一個很強大的分布式版本控制系統。它不但適用於管理大型開源軟體的原始碼,管理私人的文檔和原始碼也有很多優勢。  本來想著只把最有用、最常用的 Git 命令記下來,但是總覺得這個也挺有用、那個也用得著,結果越記越多。  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.