0

I have my local git repo that and I want to attach it to a remote git repo in a way that the remote will be like a read only version of the local git repo and will present everything in the local git repository automaticlly, without the need to push from local to remote. Meaning, if I add a new file in the local repo I will be able see the change immedietly in my remote repo before I commited or push.

I tried git hooks, but it seems that none of them fits. Actually the action I need to do is on every file that is removed or added to my local git folder to run this set of commands: "git add <file_name> ; git commit -m "auto commit" ; git push"

what is the best way to implement this solution?

thank you!

user15937765
  • 219
  • 1
  • 7

1 Answers1

0

You can't not do a push to have the remote up-to-date with your local.

You will want to create a git alias for adding new files to do the string of commands. Using this answer https://stackoverflow.com/a/25915221/498699

In your .gitconfig add this:

[alias] create = !git add $1; git commit -m "auto commit"; git push && :

Now you can run git create file1 and it will run those commands.

For updating tracked files, add a post-commit hook that runs git push after successfully doing a commit.

Schleis
  • 41,516
  • 7
  • 68
  • 87