git新建分支而且在切換分支開發

整合分支到master,忽略分支上提交的記錄git

1、git checkout master     //切換到主分支this

2、git merge --squash devbranch    //一次性合併分支的屢次提交spa

3、git commit -m '一次性合併分支的屢次提交,整合到主分支'  .net

 

git branch  git查看當前分支所屬命令行

git checkout -b preview-dev 從當前分支拉copy開發分支,建立並切換 feature 分支orm

 

git push origin preview-dev 把新建的分支push到遠端blog

 

 

git pull       拉取遠端分支ci

 

 

git branch -d preview-dev 取消新功能時,使用 git branch -d <name> 刪除分支,可是會提示銷燬失敗,這時須要強行刪除分支,使用命令 git branch -D <name>開發

 

 

 

There is no tracking information for the current branch.rem

Please specify which branch you want to merge with.

See git-pull(1) for details.

 

    git pull <remote> <branch>

 

If you wish to set tracking information for this branch you can do so with:

是由於本地分支和遠程分支沒有創建聯繫  (使用git branch -vv  能夠查看本地分支和遠程分支的關聯關係)  .根據命令行提示只須要執行如下命令便可

 

git branch --set-upstream-to=origin/遠程分支的名字 本地分支的名字   

git branch --set-upstream-to=origin/jdzt-preview-dev jdzt-preview-dev

 

提示Branch 'preview-dev' set up to track remote branch 'preview-dev' from 'origin'.

而後

git pull

success!

 

 

 摘選自 https://blog.csdn.net/stan_pcf/article/details/51911101

git將當前分支上修改的東西轉移到新建分支

好比我在A分支作了一些修改,如今因爲某種緣由(如A分支已經合併到master)不能把A分支上修改的東西保留下來可是須要把A分支上修改的東西繼續在新分支繼續修改。那麼如今咱們能夠有兩種簡單的作法完成這一需求。

第一種方法

咱們不須要在A分支作commit,只須要在A分支新建B分支,而後切換過去。這個時候你會發現修改的東西在A,B分支都有。這個時候在B分支commit,那麼這些修改保留在B分支上,再切換到A分支上會發現修改都沒有保留下來。

第二種方法

使用git stash 將A分支暫存起來,而後在某一個分支(如master分支)新建一個分支B,而後在B分支上使用git stash pop 將修改彈出到B分支上,而後這些修改就在B分支上了。而後咱們又能夠愉快的玩耍了~

相關文章
相關標籤/搜索