4

Kids if you are lazy ass like me who don't push your code more often and end up with a fuck up like this : https://devrant.com/rants/3187195/... , then here's a mini tutorial.

Title : automatically push your code on commit
Disclaimer : not the best thing to do for every situation, but definitely worth considering.
Platform : windows ( but you can figure out for other platforms too)

STEPS:
1. open .git/hooks folder
2. create file post-commit (no extension) and open via text editor
3. add code:
```
#!/bin/sh
git push --all origin
```
( or any other push statement like git push -u origin master / dev/ shit)

4. You are done. now next time you add a commit, it is automatically pushed to vcs.

good luck

=============================
PS : if you liked this tutorial and are a super smart ninja pro hackerman/women dev, then please make multiple accounts handling git credentials manager :'/

Comments
  • 3
    That's a pretty dumb idea...

    Not only is it a misusage of git hooks which might lead to all kind of problems - but you push every branch to origin.

    Please. Stop doing wrong things to fix an even more wrong workflow.

    You'll just stack frustration on more frustration.
  • 0
    @IntrusionCM its completely optional. we are manually setting up for the repos we want. i just wanted to portray an idea about executing a command automatically after running a commit.

    I can definitely see myself copying this single file for all my personal projects but not really for work projects (atleast a git push origin master , if not for all branches ^_^!)
  • 0
    and btw what more are the use case of hooks?
  • 2
    That method is fine, so long as you set up two repos:

    - The origin repo, source of truth
    - Another completely unrelated repo to house your CYA commits

    I also prefer just letting that run nightly.
  • 1
    @yowhatthefuck

    In a nutshell - what you did. ;)

    Hooks are just scripts that are ran at a certain point.

    Commit message validation, GIT change validation, automated check for linting errors and so on.

    The fun part is: It's a non validated process workflow.

    Yes. You could do an endless recursion in hooks.

    That's the dark side. Git push should be safe - but in a nutshell you're calling in a process that changes your GIT directory another command that might change your GIT directory... Sounds like bad stuff
  • 3
    Good, now your Git is suddenly Subversion 😜
  • 1
    Yo what the fuck, bad.

    Maybe with a second repo for only your commits, but you’re going to run into sync issues there.
  • 2
    @Root hehe I clearly need to get a better name . But i get your point. i think i will set up another origin for sync like this. i am just currently so fascinated by hooks and the million use cases i could think of it :->
Add Comment