Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://www.experts-exchange.com/questions/28922922/Display-the-Name-of-Current-Git-Branch.html
- Experts exchange :
- Display the Name of Current Git Branch
- Question by: Ray Paseur On 2016-02-01 10:12 PM Views 25
- I would like to be able to use PHP to display the name of my current branch. What would be a good way to discern and display which Git branch I'm currently using?
- One thought that has occurred to me would be to place a "branch-name" file in each branch, and display the information from that file. Has anybody tried something like this? Does it seem feasible?
- Thanks!
- Git Version Control Programming Web Development PHP
- Good Question?
- Request Attention
- COMMENTS
- Fouad Maidine
- Accepted Solution 2016-02-01 at 22:28:11ID: 41444176500
- Comment Utility
- In 2 lines ^^
- $root='.git/HEAD' ;
- $name= implode('/', array_slice(explode('/', file_get_contents($root)), 2));
- 1:
- 2:
- Select all
- Open in new window
- I do not know if it's the best way to do this but it works
- Good Solution? 1
- Ray Paseur
- Author Closing Comment 2016-02-02 at 16:06:31ID: 41445360
- Works beautifully! Thanks, ~Ray
- Good Comment?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement