LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-25-2024, 10:53 AM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 923

Rep: Reputation: 61
Question Old School Part Time Procedural PHP Dev here - Trying to figure out how to implement Git into my projects.


I build a lot of web based tools that aren't exposed to the internet that work with databases.

I come from the era where a lot of the tooling that modern development uses wasn't common place. If you wanted a tool that did something specific, you often built it yourself.

With that said, I'm trying to break away from this habit and get comfortable with Git. Git itself seems pretty straight forward, what I'm unsure of is how to actually use it in my day to day.

Most of my servers are setup using three sub domains, live.domain, dev.domain, test.domain. I have tools that that will rsync the roots or databases of each subdomain to and from the other. I do my development on the dev.domain, then I will sync the live.domain to the test.domain, then move my changes into the test.domain, and if all is good, I move those updates to the live.domain. Backups are taken regularly.

All three of the subdomains reside on the same physical machine and I do my editing and programming directly on the dev.domain, I do not have a local environment and I'd like it to stay this way.

So my question, how do I incorporate Git into this kind of setup? Is it even compatible? What changes would I need to make? What would my programming flow be like for new features or bug fixes? I'm open to ideas.

Edit: I forgot to mention the main reason for trying to switch to Git is so I can work on multiple features at the same time and have a system that clearly lays out conflicts between the features.

Last edited by wh33t; 01-25-2024 at 02:22 PM.
 
Old 01-25-2024, 12:45 PM   #2
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555

One of the benefits of Git is how it can be adapted to any workflow.

If you try and introduce a new tool and a new workflow, it's two things to learn, and if you picked a workflow that doesn't work well for you, it'll just be frustrating, and make it harder to learn Git.

So better to mostly stick with your current system for the time being, which is effectively a single branch with rsync replaced by git push/pull. You might also want to consider using Git just between your dev/test environments, and sticking to what you currently know and do with the live environment until you're more comfortable.


To get the current code into Git repos, there's no way around reading docs to figure out what commands/options do, but some pointers...

Convert one of the directories to a git repo, using "git init" one of the directories, adjust the ".git/config" and ".git/info/excludes" files as necessary, then "git commit --all -m 'Initial commit'" to store the initial files.

To setup a second repo, the standard method is to clone - but you already have the files there and can't clone into a non-empty directory, so instead you can manually copy the ".git" directory to the second location (using rsync or scp), and then you'll then be able to use git status to see if there are any differences, which you can commit or revert accordingly.

(If the .git directory would reside inside a public webroot, you'll probably want to first configure any live servers to block such paths, if they don't do it by default.)

Once you have both/all directories as repos, connect them with "git remote add NAME PATH" (on each repo) and use "git fetch" to sync changes, and "git status" will say you're up to date, and "gitk --all &" will tag the first commit with the remotes.

Whilst learning Git, I would occasionally zip entire directories before doing push/pull/merge operations so if I screwed up I could easily copy everything back - e.g. "tar -cvzf ~/backups/reponame_timestamp.tgz /path/to/repo" - though I don't recall if I ever needed those backups, since most situations can be recovered, but it can be reassuring to have an escape plan.


After you've worked with Git for a while, then you can decide if it makes sense to try out a more structured workflow, such as using feature branches or whatever.

 
1 members found this post helpful.
Old 01-25-2024, 02:07 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,679
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
You can use “rsync.” Or, you can clone the repo on the other machines, “git pull,” and then “checkout” the latest revision. Typically, I just sync.

“git” is very easy to use for local development because it doesn’t involve “a server.” Everything is done with local files.
 
1 members found this post helpful.
Old 01-25-2024, 02:24 PM   #4
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 923

Original Poster
Rep: Reputation: 61
I forgot to mention the main reason for trying to switch to Git is so I can work on multiple features at the same time and have a system that clearly lays out conflicts between the features.

I have updated my main post.

Basically instead of just dev.domain, I want to "essentially" be able to have dev-featurename.domain, dev-featurename2.domain, I am confused how Git would work in this scenario.

The most obvious thing to me is to somehow be able to symlink an entire directory containing the feature branches into dev.domain which makes me feel like I'm not really utilizing Git in the way it's meant to be used. It seems like Git is most commonly used with local environments, that makes total sense to me.

Btw, really appreciate the responses guys. Thank you.
 
Old 01-25-2024, 04:24 PM   #5
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555

In that case, go with a branch per major feature.

Git Flow can provide useful structure. It can also be excessive bureaucracy for an individual, but understanding the reasoning allows one to come up with something more suitable.

Don't waste time trying to do wildcard/arbitary domains - just switch branch depending on what you're currently working on. If you really must work on different branches in tandem, having primary and secondary dev repos (with static domains) might be worthwhile, but trying to deal with more than that will rapidly send one round the bend.

 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Any PHP wizards here? I am trying to figure out if PHP's built in time() and mktime() functions can understand dates beyond 2038? wh33t Programming 7 06-08-2023 12:47 AM
LXer: Gitpod git-bolts git-IDE onto GitHub for in-browser code git-editing LXer Syndicated Linux News 0 09-05-2018 04:50 AM
LXer: SprezzOS emerges, promising new-school tech with old-school gumption LXer Syndicated Linux News 0 02-01-2013 11:33 PM
[SOLVED] Can't install Git repo (I don't git git ) Nemus Linux - Software 3 05-20-2011 02:09 PM
old and medicated trying to implement Wine into puppy 431 nonext Other *NIX 2 03-16-2010 06:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration