git 使用总结(二)

使用到一些东西就自己整理一下,作为一个习惯,慢慢成长,有了问题及时改正,fighting~

1.标签
打标签
一般情况话,如果要发布一个新版本,就会对这个版本打一个标签,以便以后查看

$ git tag -a v1.0 -m 'version 1.0'  # -a便是annotated 的首字母


查看标签

$ git show [tag] # git show [v1.0]


后期加标签,如果在一次提交后没有加标签,可以用

$ git tag -a v1.1 [SHA1] # git tag -a v1.1 68bcesf


推送标签到远程

$ git push origin [tagname]


要一次推送所有本地新增的标签上,使用--tags:
 

$ git push origin --tags

2.关于分支
新建分支

$ git branch [branchname]


切换分支

$ git checkout [branchname]


新建并切换分支

$ git checkout -b [branchname]


分支合并
比如将[branchname] 合并到master

$ git checkout master


删除分支
 

$ git branch -d [branchname]

远程分支(remote branch)实际上是对远程仓库中的分支的索引,在Git进行网络交互时才会更新,而本地也会有一个远程分支,一般用(远程仓库名)/(分支名) 的形式表示远程分支
同步远程服务器上的数据到本地的远程分支

$ git fetch origin


这个命令只是将远程服务器的分支同步到本地的远程分支,对当前正在开发的本地分支没有影响

把远程分支的内容合并到当前分支
 

$ git merge origin/[branchname]

推送本地分支到远程
 

$ git push origin [本地分支名]


git rebase 和 git merge
整合分支的简单方法是git merge 命令,它会把两个分支最新的快照以及二者最新的共同祖先进行三方合并,产生一个新的提交对象

git rebase是对commit
history的改写,当修改的history还未提交到远程,对history怎么改写都行,而一旦提交到远程,就会造成别人之前(远程history未修改之前)从远程取的的分支history和目前远程的history不一致,会造成麻烦。

如果只是将本地一个分支rebase到另一个分支
 

$ git checkout experiment
$ git rebase master #将experimen分支在master分支重演
$ git checkout master
$ git merge experiment #master分支faster forward

如果远程分支有了修改,为了看到清晰的时间线,将本地分支rebase到本地的远程分支一般使用这样的方法:
 

$ git fetch origin master
$ git rebase origin/master
$ git push

Pingbacks are open.

Trackback URL

Comments

20 Comments

  • jasa posting instagram
    22 May 2019, 13:17 | Reply
    Hi there Dear, are you in fact visiting this web page on a regular basis, if so then you will without doubt get pleasant knowledge. my web site [jasa posting instagram](https://Bananapajamasid.Blogspot.com/2019/05/5-kesalahan-yang-sering-dilakukan.html "jasa posting instagram")
  • jasa posting instagram
    22 May 2019, 13:17 | Reply
    Hi there Dear, are you in fact visiting this web page on a regular basis, if so then you will without doubt get pleasant knowledge. Feel free to surf to my blog :: [jasa posting instagram](https://Bananapajamasid.Blogspot.com/2019/05/5-kesalahan-yang-sering-dilakukan.html "jasa posting instagram")
  • jasa manajemen sosial media
    26 May 2019, 16:26 | Reply
    magnificent issues altogether, you simply won a brand new reader. What could you recommend about your publish that you made some days ago? Any sure? Look into my weblog :: [jasa manajemen sosial media](https://rimarim.weebly.com/home/5-cara-memulai-bisnis-online-yg-menguntungkan-utk-pemula "jasa manajemen sosial media")
  • jasa manajemen sosial media
    26 May 2019, 16:27 | Reply
    magnificent issues altogether, you simply won a brand new reader. What could you recommend about your publish that you made some days ago? Any sure? Feel free to surf to my page
  • {hiasan dinding
    29 Jun 2019, 16:00 | Reply
    Hi, i think that i saw you visited my website thus i came to “return the favor”.I am trying to find things to improve my site!I suppose its ok to use some of your ideas!! Feel free to visit my web blog ... [{hiasan dinding](http://anggisupri.edublogs.org/2019/04/26/7-langkah-baik-mempercantik-dinding-dapur/ "{hiasan dinding")
  • {hiasan dinding
    29 Jun 2019, 16:01 | Reply
    Hi, i think that i saw you visited my website thus i came to “return the favor”.I am trying to find things to improve my site!I suppose its ok to use some of your ideas!! Here is my webpage - [{hiasan dinding](http://anggisupri.edublogs.org/2019/04/26/7-langkah-baik-mempercantik-dinding-dapur/ "{hiasan dinding")
  • Stephany
    13 Jul 2019, 19:40 | Reply
    Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I acquire in fact enjoyed account your blog posts. Anyway I'll be subscribing to your feeds and even I achievement you access consistently quickly. Here is my blog post: hiasan dinding online - [Stephany](https://galihginanjar25.weebly.com/blog/tersebut-langkah-design-rumah-dambaan-simpel "Stephany") -
  • Stephany
    13 Jul 2019, 19:40 | Reply
    Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I acquire in fact enjoyed account your blog posts. Anyway I'll be subscribing to your feeds and even I achievement you access consistently quickly. My web site ... hiasan dinding online - [Stephany](https://galihginanjar25.weebly.com/blog/tersebut-langkah-design-rumah-dambaan-simpel "Stephany") -
  • jasa personal branding murah
    16 Jul 2019, 11:54 | Reply
    Have you ever thought about publishing an ebook or guest authoring on other blogs? I have a blog based upon on the same ideas you discuss and would love to have you share some stories/information. I know my subscribers would enjoy your work. If you are even remotely interested, feel free to shoot me an e-mail. Feel free to visit my website
  • jasa personal branding murah
    16 Jul 2019, 11:54 | Reply
    Have you ever thought about publishing an ebook or guest authoring on other blogs? I have a blog based upon on the same ideas you discuss and would love to have you share some stories/information. I know my subscribers would enjoy your work. If you are even remotely interested, feel free to shoot me an e-mail. my web-site [jasa personal branding murah](http://goodjobssss.blogspot.co.id/2018/01/4-cara-membangun-personal-branding.html "jasa personal branding murah")
  • digital marketing jakarta
    20 Jul 2019, 21:11 | Reply
    Can I just say what a relief to discover a person that really understands what they're discussing online. You actually understand how to bring a problem to light and make it important. More people need to check this out and understand this side of the story. It's surprising you are not more popular since you definitely possess the gift. Feel free to visit my page ... [digital marketing jakarta](http://Winstarlink.com/ "digital marketing jakarta")
  • digital marketing jakarta
    20 Jul 2019, 21:11 | Reply
    Can I just say what a relief to discover a person that really understands what they're discussing online. You actually understand how to bring a problem to light and make it important. More people need to check this out and understand this side of the story. It's surprising you are not more popular since you definitely possess the gift. Have a look at my site
  • carontrade.com
    06 Aug 2019, 02:25 | Reply
    Thanks a lot for sharing this with all of us you actually understand what you are speaking approximately! Bookmarked. Kindly additionally consult with my site =). We may have a hyperlink exchange arrangement between us
  • carontrade.com
    06 Aug 2019, 02:25 | Reply
    Thanks a lot for sharing this with all of us you actually understand what you are speaking approximately! Bookmarked. Kindly additionally consult with my site =). We may have a hyperlink exchange arrangement between us
  • jasa Personal branding murah
    08 Aug 2019, 12:13 | Reply
    I always spent my half an hour to read this weblog's articles or reviews daily along with a mug of coffee. My web site - [jasa Personal branding murah](http://winstarlink.com/jasa-personal-branding-dan-viral-marketing/ "jasa Personal branding murah")
  • jasa Personal branding murah
    08 Aug 2019, 12:13 | Reply
    I always spent my half an hour to read this weblog's articles or reviews daily along with a mug of coffee. Check out my homepage ... [jasa Personal branding murah](http://winstarlink.com/jasa-personal-branding-dan-viral-marketing/ "jasa Personal branding murah")
  • giá xe mazda 3 sau thuế
    11 Aug 2019, 11:01 | Reply
    I am sure this paragraph has touched all the internet visitors, its really really nice article on building up new web site.
  • giá xe mazda 3 sau thuế
    11 Aug 2019, 11:01 | Reply
    I am sure this paragraph has touched all the internet visitors, its really really nice article on building up new web site.
  • giá xe mazda 3 sau thuế
    17 Aug 2019, 12:58 | Reply
    Hello there, I believe your site could possibly be having web browser compatibility problems. When I take a look at your website in Safari, it looks fine however when opening in I.E., it has some overlapping issues. I just wanted to provide you with a quick heads up! Besides that, excellent blog!
  • giá xe mazda 3 sau thuế
    17 Aug 2019, 12:58 | Reply
    Hello there, I believe your site could possibly be having web browser compatibility problems. When I take a look at your website in Safari, it looks fine however when opening in I.E., it has some overlapping issues. I just wanted to provide you with a quick heads up! Besides that, excellent blog!
Post your comment

cancel reply