====== Beacon Git setup ====== ===== Here is how the repo was initialized ===== ==== Inside cPanel ==== In cPanel, create the repository. * Where it says "Clone a Repository", click the blue slider to turn it grey * Where it says "Repository Path", this will be the location on the filesystem where the repository will be stored. Keep note of this. The cPanel user you are logged in as, the path will be hard coded to that user, but you can specify any location inside your home directory. * Where it says "Repository Name" any name can be used. It doesn't affect anything Note that one of the pieces of information that is filled out when the repository is created is a path name. Keep this full path handy for reference later when following these instructions. ==== Now in SSH/PuTTY ==== After you are done in cPanel, this is some documentation on how to get the shell side of things done. $ cd /home/beacontechnology/public_html # This creates a new repository in the current directory $ git init # now we need to stage all files recursively to initialize the repository with the current website. # this should stage all the files in the current directory recursively $ git add . # this should commit all staged files and changes to the current repository $ git commit # a nano editor will come up. # type your message at the top and leave the existing text alone. Then save and close nano like normal. # the public_html repo is now created, and all the files in the public_html directory have been added to the repo # a remote can be thought of as a "bookmark" for a remote repository, although this isn't completely true. # to add a new remote $ git remote add origin (the full path from before) # example $ git remote add origin /home/beacontechnology/mynewrepository # do the push to the new remote $ git push -u origin master Now check the history in the cPanel git interface, you should now see a new commit in the cPanel web interface. ===== Configure git user settings ===== you can configure the user information that gets put into a commit, like the users name and email address. ==== Configure settings ==== # # then run: $ git config --global user.name "Scott Brinker" $ git config --global user.email "brinker@advantech-cg.com" ==== Show settings ==== to show the currently configured information $ git config --list --show-origin | grep user file:/root/.gitconfig user.name=Scott Brinker file:/root/.gitconfig user.email=brinker@advantech-cg.com ===== General Linux help ===== ==== managing linux users ==== There is no way to configured linux users via WHM/cPanel, however doing so from the terminal is not very difficult. Lines with a dollar sign are actual commands or examples of commands to be run. Do not include the dollar sign when entering commands === Add a User === Only root can add users useradd -m newusername If you are not running as root, but have sudo/wheel permission, you can run: sudo useradd -m newusername === Set the user password === You can also use the sudo command if you are not logged in as root but have sudoers permission. passwd newuserhere Users can change their own password when they are logged in by running the ''passwd'' command. Only root can change other user passwords. === Make a user an admin === To make a user an admin, add that user to the wheel group usermod -a -G wheel usernamehere If you are not root, but are in the wheel group, you can use ''sudo'' sudo usermod -a G wheel usernamehere ===== Workflow ===== The process to change the website is something like this First make any related changes of a similar type. For example, if you are going to be fixing a bunch of similar bugs, you can change them all in one go, and put all the bug fixes into the same commit. Then run: git commit -a You will be asked for a message to describe the change. See the following for some guidance on what makes a good commit message: * https://chris.beams.io/posts/git-commit/ * https://github.com/erlang/otp/wiki/Writing-good-commit-messages * https://gist.github.com/robertpainsi/b632364184e70900af4ab688decf6f53 It basically just comes down to why you are changing it and any other information that may be useful in the future for someone coming back to look at it. The last step is to push the changes from the repository in public_html to the repository that the web interface is tracking git push origin master ===== cPanel git history ===== To see the commit history now, go to: * WHM > Account Information > List Accounts * To the left of the beacontechnology user, click the orange CP icon. * Git Version Control > History * tree means directory listing * clicking names of files will often take you to the file history page of that file. You can see a history of changes for that file * clicking diff or something similar will usually show you the actual changes made If a breaking change was made, git can help you roll back https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting ===== External resources ===== There is a full free book on git https://git-scm.com/book/en/v2 You can also view the man pages for more detailed reference style documentation You can view the man pages locally or via the hosted web https://git-scm.com/docs