Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,122
    Rep Power
    539

    More on Git, Samba, and cross platform developement


    I have spent the past few weeks learning more about Linux and revamping my server. That being said, I am still struggling on understanding how I will implement Git.

    I have two machines on a LAN, a Linux server and a Windows PC. I have a production VPS server, but let's ignore it for now.

    I have GitLab installed on the Linux server.

    I have Apache on the Linux server with my files located at /var/www/.

    I have /var/www/ mapped as a Windows folder using Samba.

    I use a PHP IDE on the Windows PC (happens to be PhpED). It directly edits the files in the Samba folder, as well as uses them for debugging. The IDE has some basic Git functionality via TortoiseGit, however, I don't yet know how strong it is.

    I've read that Git is all about being local. Giving my configuration, does that mean it is located on the Windows PC? Or is it handled just using Linux between /var/www/ and the GitLab repository? How do you envision I proceed with this?

    Thank you
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2014
    Posts
    120
    Rep Power
    6
    I think you've went way overboard here.

    if you're on your linux machine, or can ssh in do that. so long as you are in a terminal, this is what you need to do.

    The easy way

    apt-get update
    apt-get install git
    apt-get upgrade

    cd /path/to/yourproject

    git init

    git clone https://github.com/username/project.git <--replace with the url of your repo. the .git is optional

    git pull https://github.com/username/project.git <--this brings your local branches head up to the head of the repo

    git add * <-- adds all the files in your project to the repo

    git commit -a <-- nano will open up. enter a commit message, then press control+x and press y to save or n to cancel

    git push https://github.com/username/project.git <-- a prompt will appear. enter your username, then password. if you followed the steps correctly, you mill be given the commit id and you will be able to open your github project in the browser and see all of your files.

    never use a GIT gui. they are confusing pieces of crap. use the command line, you will learn to love its simplicity.

    A more advanced way

    apt-get update
    apt-get install git
    apt-get upgrade

    git config --global user.name "your github username here"

    cd /path/to/yourproject

    git init

    git remote add origin https://github.com/username/project.git

    git add *

    git commit -a <-- enter commit message press ctrl + x and hit y to save

    git push -u origin master <-- when prompted, simply enter your password. the commit will automatically be pushed to the origin branch called "master"
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1018
    Originally Posted by NotionCommotion
    I've read that Git is all about being local. Giving my configuration, does that mean it is located on the Windows PC? Or is it handled just using Linux between /var/www/ and the GitLab repository? How do you envision I proceed with this?
    You need Git on both your Windows PC and the Linux machine. You set up a bare repository on your Linux. And then you push the changes you make on the Windows development repository to the Linux repo.

    However, I don't really get the setup. How do you access the Linux repository from outside? Not at all? The point of having a central repository is to be able to access it from everywhere. If it's isolated in a LAN, it's not very useful.






    Originally Posted by r3wt
    never use a GIT gui. they are confusing pieces of crap.
    Nonsense.

    I don't know which tool you've tried (obviously not the right one for you), but GUIs like SourceTree or TortoiseGit massively improve the usability of Git. No, I don't want to look at some ASCII art when I have a complex branch graph. No, I don't want to do a large diff on the console.

    If you prefer to write down arcane commands on the console, that's your choice. But statements like “never use a GUI” are just nonsense.
    Last edited by Jacques1; April 16th, 2014 at 12:41 AM.
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2014
    Posts
    120
    Rep Power
    6
    to each his own i guess. i find the gui tools confusing. i guess they have their uses though. comparing diffs and rolling back/forward on the command line is a pain in the butt.

    What i should have said was:


    GUI tools are confusing, but they serve a purpose. if you need the basic functionality of git, just use the command line, as this will likely be all you will need while you learn to use git and push your projects to the repos. Later on, if you need to do more advanced things, like comparing accross branches and forks, or rolling back commits or even purging commits, the GUI tools come in handy.

    Comments on this post

    • NotionCommotion agrees : I think I like command line for committing, etc, but not viewing
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,122
    Rep Power
    539
    Originally Posted by r3wt
    use the command line, you will learn to love its simplicity.
    I especially see the value when initialing starting off to better understand what is happening.

    Originally Posted by Jacques1
    You need Git on both your Windows PC and the Linux machine. You set up a bare repository on your Linux. And then you push the changes you make on the Windows development repository to the Linux repo.
    I guess this is my big question. My "working" version of the code is located on the Linux server, and is available to the Windows PC via a Samba shared drive. Why add/commit/etc using the Windows PC when I could do it directly from the Linux server? I am not saying you are wrong, only that I am still uncertain.

    Originally Posted by Jacques1
    However, I don't really get the setup. How do you access the Linux repository from outside? Not at all? The point of having a central repository is to be able to access it from everywhere. If it's isolated in a LAN, it's not very useful.
    Currently, the only point is version control. Does not this reason in itself fully justify utilizing Git or some other similar system?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,082
    Rep Power
    381
    git commands are confusing and not at all intuitive.. at least a GUI will somewhat help you do stuff easily
  12. #7
  13. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1018
    Originally Posted by NotionCommotion
    My "working" version of the code is located on the Linux server, and is available to the Windows PC via a Samba shared drive. Why add/commit/etc using the Windows PC when I could do it directly from the Linux server?
    So you wanna work on your Windows PC, but whenever you make a relevant change, you log in to your Linux machine and commit them there? Why would you do that?

    I think a lot of the confusion comes from the somewhat strange setup. You have two machines, but they just share the exact same data, and none of them is accessible from the outside. In this scenario, all you can do with Git is track changes (with a single repository). There's nothing to distribute and no separation of different stages (development vs. live).

    My personal setup looks like this: I have a central Mercurial repository on a public server and several local repositories on different development machines. Whenever I've finished work on one of the PCs, I push it to the central repo. Whenever I use a different PC, I pull the current state and continue. And when the application goes public, I make yet another repository for the live files and use it to pull specific states from the central repo.

    If you don't want a public server for now (which is a good idea), you should at least have separate repositories on the two PCs and get rid of the shared folder. Use the Windows repo for development, testing and trying out things. Use the Linux repo as a staging environment for the files you'll eventually put online.
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,122
    Rep Power
    539
    Originally Posted by Jacques1
    So you wanna work on your Windows PC, but whenever you make a relevant change, you log in to your Linux machine and commit them there? Why would you do that?
    Because I don't know what I am doing . I originally was thinking I would do a git status, and then select the files to commit, but in hindsight that sounds like a royal pain in the butt.

    Originally Posted by Jacques1
    I think a lot of the confusion comes from the somewhat strange setup. You have two machines, but they just share the exact same data,
    ....
    you should at least have separate repositories on the two PCs and get rid of the shared folder. Use the Windows repo for development, testing and trying out things.
    Only one PC, not two. The reason I want the code on the Linux server is the application uses symbolic links and multiple shell Linux commands, and I can't test it directly on the Windows PC. If I get rid of the shared folder, my work flow would be: 1) Type some code. 2) Save it on the PC. 3) Upload it via SFTP to the Linux development server. 4) When I am satisfied, stage and commit it the the repository. The shared folder gets rid of Step 3, however, all other steps would be the same. I am obviously missing something here.
  16. #9
  17. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1018
    Originally Posted by NotionCommotion
    I am obviously missing something here.
    You have two repositories: One on the Windows PC, one on the Linux server.

    You work on the Windows PC and commit all changes into its local repository. When you feel the need to test a specific state, you go to the Linux repository and pull the corresponding changes from the Windows repo.
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,122
    Rep Power
    539
    Thank you for your clarity. Given my wondering, I needed it.

    I noticed you didn't say "three repositories" which makes me realize that I don't need a GitLab repository if I am not collaborating.

    I still don't like the idea of committing before even a quick test, but guess that is the way it is.
  20. #11
  21. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1018
    The common mantra is “Commit early, commit often”. You don't need clean snapshots in your local development repository. You just commit every relevant changeset and do the picking in the staging environment.

    Git also offers extensive features for history rewriting. When you've finished a feature, you can clean up the history and make it look pretty.
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  22. #12
  23. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2014
    Posts
    120
    Rep Power
    6
    paul, i spent months trying to understand and use git with the github gui tool for windows. it wasn't until i tried just plain old git on my linux machine that i finally understood and could use it. i was able to take that knowledge and use it on windows when i installed git bash. I realize most people are visual learners, but some people are not. i'm one of those people i guess. The point i'm trying to make is there is no one size fits all. what works for me might not work for you at all, and vice versa.
  24. #13
  25. Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    New Springfield, OH
    Posts
    1,312
    Rep Power
    1503
    I use a Git service (typically Bitbucket or Github) to house my repository. I develop on my local machine and push to the remote often. I keep a "production" branch that represents my live server with a hook. When a change is tested and ready to roll out, I merge it into the production branch and it gets automatically pushed out to my live server.
    Last edited by Nilpo; April 16th, 2014 at 02:34 PM.
    Don't like me? Click it.

    Scripting problems? Windows questions? Ask the Windows Guru!

    Stay up to date with all of my latest content. Follow me on Twitter!

    Help us help you! Post your exact error message with these easy tips!
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,082
    Rep Power
    381
    Originally Posted by r3wt
    paul, i spent months trying to understand and use git with the github gui tool for windows. it wasn't until i tried just plain old git on my linux machine that i finally understood and could use it. i was able to take that knowledge and use it on windows when i installed git bash. I realize most people are visual learners, but some people are not. i'm one of those people i guess. The point i'm trying to make is there is no one size fits all. what works for me might not work for you at all, and vice versa.
    what I meant was, some of the commands do not make sense.. there was this great blog post I read somewhere that shows how un-intuitive the commands are.. for example:

    git checkout foo.txt add file to staging area
    git reset HEAD foo.txt Undo local changes (like svn revert)

    the two commands do the opposite but are not very like.. i would not know to use that..

    But of course if I was to learn the commands properly, command line would be ok to use.. but still you have to type in the long commands etc without making mistaked

    Comments on this post

    • r3wt agrees : seems like the creators of git wanted to build in some "job security" heh
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,122
    Rep Power
    539
    Originally Posted by paulh1983
    but still you have to type in the long commands etc without making mistaked
    Ah, seems like a good application for aliases! Needless to say, I am still reading the book I bought, and am still on the "aliases" part
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo