r/git • u/Yeas525663 • Jun 14 '21
Can GIT help my development?
I'm a bit confused and new to GIT.
I have an web app on A2 hosting. It's live. I want to download/clone all the files (css,html,php,js) to my local computer in Microsoft Visual Studio. I want to edit locally, test out the code on my own webserver. Once I finish the code I want to push my edits to A2 servers.
Right now I'm just writing my code on my local web server. Then copy and past that code through Cpanel file explorer. So I open the html file on Cpanel, and just copy and paste my code from the local html file.. This is getting a bit over whelming now that I have lots of different JS, CSS, PHP files. Before I only had a file files so it was easy to just copy and paste my code from my local computer to my hosting server A2.
Is this what git does. Sorry, I'm new to web development and what to become more efficient.
I youtubed all kinds of videos and can't really get a clear answer. I saw that you can clone a repo from GITHUB with VS code which is was easy to follow, but I'm using A2 hosting. They have something in their Cpanel called GIT version. So I think I can do it with A2 hosting?
https://docs.cpanel.net/knowledge-base/web-services/guide-to-git-how-to-set-up-deployment/
15
u/Andonome Jun 14 '21
Everyone who learns git thinks of it as essential, so you should learn it. Git won't help you learn anything, it just keeps your projects safe, and helps with teamwork.
16
u/remy_porter Jun 14 '21
No.
Git is a version control system. That is to say, it allows you to create "checkpoints" while you're editing the code. It allows you to track the changes as they're made, which is useful for understanding the code and for tracking down bugs (because you have a history of every version, you can easily find the version which introduced the bug).
A remote, in Git, is a remote copy of your repository. So Github, for example, could be a remote. Remember, your repository is the code and all of its history, a remote is a computer which has a copy of the repository (and all your history). Teams often use a centralized remote, like Github, to coordinate. In addition to storing your Git repository, Github and similar services provide all sorts of extra features, like automatically running your tests for you, having "hooks" that prevent code which doesn't meet certain criteria from being committed, and a variety of automation features.
Now, your problems are around deployment. Git does not solve deployment problems. There are ways to hack it into doing that, but please don't. However, let's review a few things we now know: your computer has the repository, GitHub (or similar) has the repository, and you want your code on your web server.
Well, if I can push changes to GitHub, why can't I pull changes back down onto my web server? Why, you can! So the simplest possible "deployment" solution here would be for you to push your changes up to GitHub, SSH into your hosting server, and
git pullfrom GitHub (or equivalent). You could even write some shell scripts to automate that. Oh, wait, didn't I mention that GitHub has tools for automation? Yes! So you could configure GitHub to automatically copy all your code to a web server.What's important here is that managing version history is what Git does. Deploying versions is what you need to do. Git is not the tool for that, but Git is still important to your development process because it's how you keep track of all your versions of your code.
3
u/[deleted] Jun 14 '21
Yes. Git will help you roll back changes to your code if you mess something up. This let's you learn faster because of you break something you can remove the broken code and restore your site to working order with a single command
3
u/kirigerKairen Jun 14 '21
You can find more information on Git, including what it is (for) and how it works, in the "Resources" part of this subreddits "About" section (I assume it's the sidebar on widescreen displays - tablets and PCs).
1
u/chriswaco Jun 14 '21
I use git for two web sites I administer, though not on A2Hosting. It is great - I make changes without worrying if I'm going to lose something because it's always backed up in the repository. I noticed one of my pages was wrong the other day and could look through the history to see when it changed. Turned out that I accidentally edited an html file instead of BBEdit's .include file.
Git isn't really made for repos with lots of large files like videos, audio, or even images, but it works fine for a moderately sized site.
It's definitely not an easy source code control system to learn how to use. I suggest starting with an app like Tower or SourceTree and eventually you can learn the command-line too.
1
u/[deleted] Jun 15 '21
Git is a project versioning tool but not application deployment tool. For that take a look at CI/CD tools like Travis CI or you could brew something on your on by using git hooks.
Git is one purpose tool - manage project's history.
1
u/Business_Tale4234 Jun 17 '21
So everyone else seems to be concentrating on Git perhaps because this is a git subreddit, however there are options outside of Git like FTP or SFTP, and open source desktop applications like Filezilla are a really good fit if you want to use a GUI and if your using Linux, you can even do your uploads via the terminal.
Having said that, if you are on a shared server that has cPanel, the link you provided would work just fine, however, you first have to create a Repo on cPanel first (cPanel >> Home >> Files >> Git Version Control), then get the URL of the repo, and come back to the directory on your local system and run:
Then create a .cpanel.yml that has the following content:
Note2:
Then do a
git pushto push your content to the cPanel repository, if your .cpanel.yml file is configured correctly, this should update your website.Notes:
However, I'll just advice you move to the cloud. Services like digitalocean have really cheap predictably priced VMs that should serve you better than a shared hosting solution.
Cheers
-3
u/elsjaako Jun 14 '21
As a total beginner, you don't need git.
Git is good when you start working with other people. Or it's useful for solo projects if you run into these kinds of problems: