I want to know if there's an option to disable committing to a local branch. I forget sometimes to open a new branch when developing. Thanks in advance.
            Asked
            
        
        
            Active
            
        
            Viewed 91 times
        
    0
            
            
        - 
                    The question is a bit confusing. Why would you not commit to a local branch? – TheGeorgeous Nov 08 '17 at 07:49
- 
                    We have a branch in the server that no one pushes too. My problem is that you can commit to the local branch. I want to diaable that option. – Amit Toren Nov 08 '17 at 09:36
1 Answers
0
            There are hooks you can install which get executed before a commit. See here.
Also if you have already written code and realize you're on the wrong branch you could git stash the changes.
 
    
    
        Sogomn
        
- 304
- 3
- 16
- 
                    I tried doing git stash but it weirdly put some unknown files in my commit. Maybe I did something wrong. Are the hooks going to work on a commit to a local branch? – Amit Toren Nov 08 '17 at 12:29
- 
                    
- 
                    I want a branch that the only action you can do on it is pull. It's the dev branch that everytime a branch gets approved it upload it to the dev branch. So the only thinf I want permitted on the dev branch is pull. – Amit Toren Nov 08 '17 at 13:16
- 
                    That should be possible with a pre-commit hook. https://git-scm.com/book/gr/v2/Customizing-Git-Git-Hooks – Sogomn Nov 08 '17 at 13:18
- 
                    Also you could manually alias all git commands to execute a script instead. – Sogomn Nov 08 '17 at 13:20
- 
                    
