Now anyone can push and pull directly from master branch, and their pushed changes will automatically be placed in our deploy folder. To create other repos for other developers:.(For me, this is just an index.html file.) If you look in the deploy folder, it should have your latest pushed changes.From an individual developer’s repo, use this command (or a GUI) to push changes to the bare repo. Let’s back out of the hooks folder back to our site’s root directory and create it. We also need to make sure that the “ app” deploy folder which this post-receive hook wants to deploy to actually exists.If you want to make more changes to the post-receive hook, and test them quickly, take a look at this article. You can easily upload the full contents of your deploy folder to your production web sever, without worrying about accidentally including extraneous version control files. git folders or other version control info will be placed in the deploy folder. Now, whenever changes are pushed to the bare repo, they will be automatically copied to the desired deploy folder. Deploying $ branch may be auto-deployed to the \"$DEPLOYDIR\" folder." # Only auto-deploy (checkout) the $BRANCH specified above.Įcho "Branch $ref received. git/hooks folder and set as executableĭEPLOYDIR=./app # The place to deploy to. (Located in the -bare repo's hooks folder.)" (This post-receive script was based on this one.) #!/bin/shĮcho "Executing post-receive script. You shouldn’t have to change anything else. app (near DEPLOYDIR) to be the actual name of the folder you wish to push to. You could use a command line editor like nano or vim, or simply open the file in a text editor such as Notepad or Atom. Edit the post-receive script to add the following code.Note, the post-receive file won’t have any extension. Go ahead and navigate to the hooks folder, and use touch to create an empty file named post-receive. Before pushing for the first time, let’s set up a git hook to automatically copy pushed changes to a folder.Add the app.git bare repo as this repo’s “origin”.Commit all files (can be done on command line or with GUI.). Stage all files (can be done on command line or with GUI.).In my example I simply added an index.html file. Add any of your app’s existing files to this newly created repo (the app-developerOne folder).Normally I’d name the developer repos after my developers, but for this example I’ll just call our first developer “developerOne” Next, back out of the app.git folder, then set up a repo for your first developer.You can read more about bare git repos here. Bare repos don’t even show the source-controlled files–they have no working or checked out copy of these files. No one will ever directly edit the files in the bare repo. Developers pull latest changes from this repo into their personal repositories, then later push their changes back into this repo. Why a bare repo? A bare repo acts sort of like your team’s “GitHub”. (The next few commands are based on this stack overflow answer.) mkdir app.git For this example, we’ll pretend the name of our application is app and call the bare repo’s folder app.git accordingly. Conventionally, the folder that is used for your bare repo should end in. We’ll be using the bash command line for most of this guide. In the end we’ll expect to have a structure that looks something like this. This workflow works great for projects like websites and web applications. You’ll set up a repository for each developer, a central bare repository for them to push files to, and a git hook to auto-deploy files to a folder of your choice. Want to use git for a small team of developers, but can’t (or don’t want to) use a git server? No problem! All you need is a shared network drive (like a dev server) that all of your developers can access.
0 Comments
Leave a Reply. |