[Git] Remote Branch and Tag

复制代码
/**
    Remote branch and tags
*/
$ git checkout -b shopping_cart                                                                //switched to a new branch 'shopping_cart' and checkout(Locally)
$ git push origin shopping_cart                                                                //Links local branch to the remote branch (remote tracking)
$ git add cart.rb                                    
$ git commit -a -m "Add basic art ability"
$ git push                                                                                    //Now, we put all the local stuff to the remote branch shopping_cart


//If use:
$ git branch
    * master
/*You will not see the remote branch, By using:*/
$ git branch -r                                                                              //list all remote branches
    origin/master
    origin/shopping_cart
$ git checkout shopping_cart
    Switch to a new branch shopping_cart

/*Remote show*/
$ git remote show origin

/*Removing a branch*/
$ git push origin :shopping_cart                                                               //deletes remote branch, you still have local branch
$ git branch -d shopping _cart     
//It might show the error: The branch 'shopping_cart' is not fully merged.
//If you really want to delete it:
$ git branch -D shopping_cart


/*To clean up deleted remote branches*/
$ git remote prune origin                                                                    //remove branch reference

/*Remote branch names*/
//heroku-staging: only deploy on the master branch
//if you do:
$ git push heroku-staging staging
    Would not work, would push to staging

$ git push heroku-staging staging:master
    Will push and deploy staging on keroku
    
/**
    Tagging
*/
/*A tag is a reference to commit relase versioning*/
$ git tag
   v0.0.1
   v0.0.2
 
$git checkout v0.0.1   checkout code at commit

//To add a new tag
$ git tag -a v0.0.3 -m "version 0.0.3"

//To push new tags
$ git push --tags

//Retrive tag version
$ git checkout v1.3.1



------------------------------------------
1. create a local branch hamsters 
     $ git branch hamsters
2. check out the local branch
    $ git checkout -b hamsters
3. push local branch to the remote branch
    $ git push origin hamsters
4. "git branch -r" does not query the remotes to check for new branches.
 In order to see a new remote branch you first have to do a fetch or a pull. So retrieve the remote "weasel" branch
    $ git fetch
5.  Get a list of remote branches
    $ git branch -r
6. delete the remote branch
    $ git push origin :weasel
7. Check for stale branches that are tracking "origin"
    $ git remote show origin
8. You still have a stale local branch tracking the now-deleted origin/weasel. Clean up your local references.
    $ git remote prune origin     
9. List tag
    $ git tag
10. create new tag
    $ git tag -a v1.3.2 -m "Version1.3.2"
11. push tag
    $ git push --tags
12. The client is requesting that you roll back to the prior release. (Seriously? What could have gone wrong with the hamsters?) Retrieve the release tagged "v1.3.1".
    $ git checkout v1.3.1
13. git checkout tags/1.0.0 -b <new_branch_name>
复制代码

 

posted @   Zhentiw  阅读(951)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示