Gitolite update copy at server when push - gitolite

In gitolite I've set up a new repository on the server and able to clone it from my machine.
As it's a web project I need the latest working copy at /var/www/my-project, so every push made by a developer will update the files there. How can I achieve that?
thanks

The repos managed by gitolite are managed in ~/repositories
You can add your own hook in ~/repositories/yourrepo.git/hooks called post-receive hook in order to checkout, on each push, the index to a working tree of your choice (like
/var/www/my-project)
See for instance "how to process files on a branch in post-receive hook in git" (which can even check for which branch is pushed).
The checkout uses:
git checkout --work-tree=/var/www/my-project

Related

How to push changes from GitHub Desktop to Cpanel

Is it possible to directly push changes to a cpanel repository from GitHub desktop software. Or first the repository changes will be pushed to the online repository on github.com and then from there the cpanel will fetch the changes by clicking Update from Remote & Deploy HEAD Commit
One possibility would be to use a GitHub Action, that is a process able to run on GitHub side, triggered by a push.
For example, a deployment action, like one to publish to Netlify or zem
You would need to adapt such an action to push/publish to Cpanel, using an API key.
Clone the remote repository on your cPanel account to your local computer. git clone URL
Create the .cpanel.yml file.
Add the cPanel-managed repository as a remote. git remote add origin URL
Push changes to the cPanel-managed repository. git push -u origin HEAD
For more information: https://documentation.cpanel.net/display/CKB/Guide+to+Git+-+How+to+Set+Up+Deployment

How do i add and sync my local git on server? What is bare repo?

I am using git from a long time but never set it up on server. Refereeing to this Git: move existing repository from PC to server, clone from server
I have initiate a bare repo on server but while adding origin in local
"git remote add origin server:path/to/repo" i have no idea what to add here. My site is getwalkwel.com and user is getwamld
Thanks
Origin is the name of a remote which is typically created automatically when you clone a repo from another repo. The origin reference in the cloned repo will be created to point back to the repo that was cloned from.
In your case, where the bare repo was actually created later from your working repo, you will create origin in your working repo to point back to your new bare repo.
This is done with:
git remote add origin /barerepo/fullname
If your bare repo is going to line on a different machine, then you need the URL to reach the repo instead of just a file path.
For instance, you might have myuser#myserver:path/to/repo
Bare repository in Git is a repository which only contains version control information only in fact this will not have .git sub-directory or any working files.
This kind of repository is helpful when you need to share or divide your work between few people for example in work environment you and your team mates are working on same project and you all need to see changes and all needs to do push to repository in this case this repository is more useful.
You can add the remote repository to local git repo
$ git remote add origin ssh://myserver.com/var/git/myapp.git
pushing to remote repository:
to push our local master branch to the origin's master branch. You can do that using the git push <target> <local> command.
$ git push origin master
click here for more information on how this works

How to clone git repo from Windows to Linux?

I previously kept a bare git repository on a Linux server and a working copy in my local Windows laptop for development (syncing to the server using TortoiseGit over ssh). The server version was deleted/lost so I want to recreate the repo on the server using the latest commit from the local working copy on the Windows machine.
What is the best way to create this new remote bare repo copy on the remote Linux server from the Windows working copy?
You can re-create the linux server repo using
mkdir -p myrepo.git
cd myrepo.git
git init --bare
On the local copy, assuming the remote URL is the same, do
git push origin <branch refspec>
for example
git push origin master
Note: If the remote URL has changed you can use
git remote set-url origin <new-url>
Just create the repo on the server, then add the repo to your local one as remote if it is not the same location as before and push to it.
Follow these steps:
Create a bare repository on remote.
I guess the answer provided by ad22 is good enough for you:
mkdir -p myrepo.git
cd myrepo.git
git init --bare
Otherwise, you need to find out how to create a bare repository on server.
Copy or Memo the URL of that just created bare repository.
(Of cause, you need to have the right for accessing the URL.)
Add a new remote for your local repository.
Since you already have a local repository,
Right click in that repository, Click TortoiseGit -> Settings,
Give the remote a shortname and URL you copied
Add it and apply the setting.
See:
Push to remote by right clicking in local repository and click Push item.
In Push dialog,
Select the remote you just added.
Check the Push all branches checkbox if all branches can be public, otherwise you need push each branch one by one.
Check the Include Tags checkbox if you want to push all tags.
Suppose that's all. ^__^
On your Windows machine:
git clone --bare /path/to/local-working-copy-of-the-repo
The above command will create local-working-copy-of-the-repo.git folder.
Now copy the folder(bare repository) on to the Linux server.
Hope this helps.

How to connect local and remote Mercurial repos?

Typically, in Mercurial, I create a new project by:
Create a new remote repo
Clone the repo locally
Make changes to the local repo
Push those changes to the remote repo
The "remote repo" here is actually our "central/originating" DVCS server (http://ourhg.ourorg.example.com, etc.).
I am now in a situation where I had to use a code generation tool to produce the source code for a simple web app. So the source code exists before the remote repo exists on our hg server. I'm looking for the exact shell commands I need to execute to get this properly pushed to the remote repo.
I believe it should be something like this:
Use the code generator to generate the code, say, at /home/myuser/myapp.
Initialize an hg repo for myapp locally on my machine (hg init)
Add the generated source code for myapp to this local repo (hg add, then hg commit)
On ourhg.ourorg.example.com, create the new remote repo (manual steps)
???
Push the changes sitting in my local repo to the remote repo (hg push)
I know there is something missing in between Step #4 (creation of the remote repo) and Step #6 (pushing to the remote repo). There surely needs to be some "connection" step where my local repo and the remote repo realize they represent the same project/source code/etc. This is my hangup here, so I ask: what is Step #5?
what is Step #5?
Discover URL of this repo. Because it's empty repo, you can don't worry about "related|unrelated"
There's nothing you need to do to associate them. You can do hg push URL_OF_REMOTE on your local and it will work. If you don't want to have to provide the URL each time you can edit (creating if necessary) .hg/hgrc in the repo and set the default= value in the [paths] section. Something like this
[paths]
default=URL_OF_REMOTE
That's optional though.
Just use your origial steps, with caveat:
Create a new remote repo
Clone the repo locally (this will set default path of local to remote).
Make changes to the local repo (Use the code generator app to generate the code in the local repo).
Push those changes to the remote repo.
With this flow, you don't have to manually update the path to the remote repo.

git server and client set up in linux

i am new to git and now i am trying to set up a git server and want to access the server from client.
referred many links but those are not helping me. i tried with the link http://davedevelopment.co.uk/2010/12/05/how-to-install-gitolite-on-ubuntu-10-10-maverick-meerkat.html. after the final step in the document i didn't know how to proceed.
can anyone give the details?
thanks in advance.
if you have cloned a repository on your client you are ready to start coding...
git commit
to commit changes locally, and
git push
to push your changes to the server.
What is missing on the above answers is how to push on the server a new repo.
Suppose that in the gitolite config file you have a repo named my_repo, you can add to the server an existing local repo this way:
cd my_repo
git remote add gitolite git#your.git.server:my_repo
git push gitolite master
You have to type ONLY ONCE the second line above. After that, you only have to push.

Resources