I have a git server where many of my repositories are being handled. I have a Raspberry Pi (which is globally accessible) setup in testing department. What I want to do is, I want to push the code from my PC to git server and that Raspberry Pi would automatically detect the push and do a subsequent git pull to update its repository.
I have used GitHub and it is VERY easy to do that in Github as it has a builtin Webhook page where I added a link of one of the php files in my Pi. That php file contains nothing but git pull so whenever I push something from my PC to GitHub, it executes that php file in Pi and it does a git pull and updates itself automatically.
I have also used a githook post-receive but it needs to setup on server and client both and it was a lot of work but I finally did it. still the repo was not being updated as I pushed the code.
I want to do the same exact thing which Github is doing but with Git. I am using Gitolite for managing Git on my server
Related
A have a rasberry pi(Debian) with a local git server in it. I was able to push normal files to the repo but when I try to push big files it gives me this error.
batch request: bash: git-lfs-authenticate: command not found: exit status 127
Im connection to the rasberry via ssh.
I have installed in both sides git lfs (maybe I did it wrong)
I was able to use git lfs to push into GitHub but not into my local server.
Do I have to create a different type of server of just with the git one should work;
Git and Git LFS are two separate projects. Git includes a server which can be used over the SSH protocol, but Git LFS does not.
There are two possible approaches for using Git LFS over SSH. The older form uses a program called git-lfs-authenticate, which provides authentication for an HTTP server, and then the data is uploaded over HTTP or HTTPS. If you're using Git LFS 3.0 or newer on the client side, it also supports a pure SSH protocol using the git-lfs-transfer program. While Git LFS does not include that program, the reference implementation is written in Rust and can be built with cargo install scutiger-lfs (which can be adjusted to install where you'd like it to be located). That program will need to be installed on the server side in the PATH for it to be available.
I have a VPS (OS: centos/debian) now. What I want is to develop my own website (RoR/python) and write some functional programs like parser, email sever and so on. What I am doing now is to write code and use ftp to push my code then use the root shell (which is lag and slow) on vps to run and debug. This is killing me. Can anyone tell me how to deal with this? And use what to replace the root shell?
Try this.
On your VPS install git
Clone your repo and checkout a branch called production or something like that
On your dev machine commit all code you want to deploy
Merge it into production branch
Login to VPS and cd into folder you cloned in step 2
git pull should bring in all changes from git on production branch
All this can be automated but if you try this with a simple html file you will understand the process and feel comfortable doing gulp or grunt based automation of each step. Ideally you can have a task runner on development machine that will run deploy task and ssh to your vps, change directory to your git folder and pull changes, may have to stash existing changes and also backup last version somewhere else and run database migration if needed etc. But dont worry about all of this at this stage.
I have been attempting to use hooks to automatically pull the updated repo from github to my remote web server. This is the code on the post-receive hook:
cd /home/[my username]/document_root/[github repo name]/
git pull origin master
I expect this to run when there is a new commit from my development machine that syncs with the one on github, but it doesn't update the files inside of that repo directory. Any help is appreciated, but I am new to using git and github in general.
EDIT: I tried to follow this tutorial but it still doesn't work.
http://ryanflorence.com/deploying-websites-with-a-tiny-git-hook/
You can push git post-hook to Github. Instead, you can use Github's Webhooks
you can customize a schedule with crontab.
for example, crontab -e , and input
5 * * * snyc_git.sh
Then it will snyc your respository.
Previously and on my local machine, I've been using nodemon which watches for changes made to a Node app and reloads it upon every change. But running the development server on my own machine is no longer feasible, so I've setup git for the app on a designated development server.
In advance, I prefer Sublime Text, so editing files on the development server via the terminal doesn't match my workflow, plus I like having a copy of everything on my local machine by default. I had also checked out rsync, but I like the fine-grained version control that git offers.
So how can I edit files locally, git push them to a development server, and have the Node app automatically reload after every push?
You can write a server side hook. In your .git directory there is a hook directory. Just cd in to .git/hooks. There you can write a script in whatever language you need to write it in. Essentially after you push it will run the script you tell it to. Here is more information on git hooks
https://git-scm.com/book/es/v2/Customizing-Git-Git-Hooks
Quick tutorial to make this work:
On the development server, navigate to /home/dev-user/Node and initialize bare repository at /home/dev-user/Node/example.git using git init --bare example.git.
Clone repository into /home/dev-user/Node/example using git clone example.git.
Add files to /home/dev-user/Node/example as necessary, then git add . and git commit -m "init" and finally git push origin master which will push those files to example.git.
Edit or create /home/dev-user/Node/example.git/hooks/post-receive and add the following line:
GIT_WORK_TREE=/home/dev-user/Node/example/ git checkout -f
This will automatically update the files in /home/dev-user/Node/example/ upon any changes pushed to /home/dev-user/Node/example.git.
If you don't have nodemon installed already, install it with npm install -g nodemon. You may have to use sudo.
Assuming your main Node app is located at /home/dev-user/Node/example/app.js, start the app using nodemon /home/dev-user/Node/example/app.js (or if you're already within /home/dev-user/Node/example, just nodemon app.js of course).
On your local machine, navigate to /home/timbur/Node, and assuming you're able to connect to the server automatically via SSH, clone the bare repository using git clone dev-user#dev.server.ip.address:Node/example.git. You'll now have everything in /home/timbur/Node/example.
Edit files on your local machine and add/commit/push files to the development server as usual, and changes will automatically update the server's example directory, which nodemon will detect and the app will be restarted.
The best way would be to setup a continuous integration server, like Jenkins: https://jenkins-ci.org/
And then there are plugins for basically whatever you want to do, like this one for node.js for instance: https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
But that's probably not the easiest way. You could also setup a post-receive hook on your server, that checks out the code whenever you push any changes, and then let it restart your server. Here's a gist I found (but never tried) https://gist.github.com/tlrobinson/8035884
I am fairly new to Git. I have worked locally, but today i need to setup a remote machine with the git. I have no idea how.
Basically my setup is like this.
I have a windows machine which has a vmware player installed, which is used to connect to the dev ubuntu linux machine where out Git repo is situated. I putty to the dev machine and do all the operation related to git with username common to all the developers username : dev
Now there is a new rollup that is created in the dev git repo which is required to be deployed on our ubuntu linux test server. I have my account in test server. username:ash.
What are the steps that should be followed to setup this. I have some time back had a discussion with one of my colleague who had shared about using SSH key. As he is the only contact person who is not available, I have no info how to proceed. I have created the SSH key.
login to the machine as "ash".
ash#gitserver:~$
create a new directory that will contain the git-repository
ash#gitserver:~$ mkdir rollout.git
change into the directory
ash#gitserver:~$ cd rollout.git
initialize the git repository
ash#gitserver:~/rollout.git$ git init --bare
go back to your dev machine and clone the newly created repository or add it to the "remote"s of an existing git repo. use "ssh://ash#gitserver/~/rollout.git" as the remote-url.
[update for cloning]: make sure that there is not already a "rollout" directory in the directory where you want to clone to. for simplicity, create an empty directory "foo/" and try to clone into that directory. you can then move the cloned repository to wherever you want to.
push changes to the new repository.......done!
the use of ssh-keys will make authentication simpler and/or more secure but is in no ways necessary (or related) to setting up the git repository.