Thread: A git flow for single-user development on multiple machines

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446

    A git flow for single-user development on multiple machines

    I've moved recently to git and am trying to decide how to best take advantage of it in the following project scenario:

    - Single user development
    - Development happens anytime on one of three computers
    - These computers don't connect to a common network
    - Project sources are moved between computers on a pen drive

    Currently I'm copying the project .git folder along with the sources into the pen drive. But I don't want to risk corrupting my git repository elsewhere if by chance the copy happens with silent errors.

    I don't want to use the pen drive as a central repository either. For the same reasons. But I need to share the git repository between all three computers.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Mario F.
    Currently I'm copying the project .git folder along with the sources into the pen drive. But I don't want to risk corrupting my git repository elsewhere if by chance the copy happens with silent errors.

    I don't want to use the pen drive as a central repository either. For the same reasons.
    But you won't get silent errors if you merge from or rebase onto the pen drive central repository and test, then push to the pen drive central repository.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    AFAIK, git does a lot of hashing and checking to see if there are errors.
    Can you force an error that can not be detected by a 'git status' ?

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Currently I'm copying the project .git folder along with the sources into the pen drive.
    But I don't want to risk corrupting my git repository elsewhere if by chance the copy happens with silent errors.
    O_o

    You should stop doing things by hand.

    Copy-To-USB): Use `git' to publish--merge/whatever--to the pen drive as a repository.

    Copy-From-USB): Use `git' to subscribe--pull/whatever--from the pen drive to your active machine.

    [Edit]
    Yikes. Twice in five minutes...
    [/Edit]

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Ok. I think I'm getting the hang of it. Thanks.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I use bitvise ssh server to host my "central" git repo's. If anyone wants the settings to use, let me know.

    gg

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Here's the pattern I would use:

    At the end of a work session, "git clone" your repo from the workstation onto the USB stick.
    At the beginning of a work session, "git pull" from the USB stick to the repo on the workstation (if it's a different workstation than last time). Then DELETE the repo off the USB stick.

    I would absolutely not copy .git folders to and fro.

    BTW, I solved this problem for myself by installing GitLab on one of my cloud instances. It's like my own private GitHub, complete with merge control and issue tracking.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by brewbuck
    At the end of a work session, "git clone" your repo from the workstation onto the USB stick.
    At the beginning of a work session, "git pull" from the USB stick to the repo on the workstation (if it's a different workstation than last time). Then DELETE the repo off the USB stick.
    What's your rationale for always doing a git clone and "DELETE the repo off the USB stick"?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Then DELETE the repo off the USB stick.
    O_o

    A protocol which asks that I delete a valuable backup is not a protocol to which I will agree.

    Using "git" will ensure, hopefully, that you don't override good data with bad.

    However, "git" doesn't do silvering. If the local data is even a little trashed, you can't restore with a `git' command.

    [Edit]
    Depending on which bits get corrupted, you could recover some objects from the repository by looking through the history.

    Why go through the trouble when you could just keep an extra copy around?
    [/Edit]

    Soma
    Last edited by phantomotap; 02-18-2015 at 01:46 PM.
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  10. #10
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Ok. ermm...

    To be clear, if I clone the repo, make changes to the copy on the same branch and commit, I cannot push the changes to the origin? I'm getting:

    remote: error: refusing to update checked out branch: refs/heads/master
    remote: error: By default, updating the current branch in a non-bare repository
    remote: error: is denied, because it will make the index and work tree inconsistent
    remote: error: with what you pushed, and will require 'git reset --hard' to match
    remote: error: the work tree to HEAD.
    remote: error:
    remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
    remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
    remote: error: its current branch; however, this is not recommended unless you
    remote: error: arranged to update its work tree to match what you pushed in some
    remote: error: other way.
    remote: error:
    remote: error: To squelch this message and still keep the default behaviour, set
    remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
    How exactly do I push my changes to the USB pen origin after a day's work on my remote repo?
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  11. #11
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by laserlight View Post
    What's your rationale for always doing a git clone and "DELETE the repo off the USB stick"?
    Because Mario said "I don't want to use the pen drive as a central repository either."

    Blowing it away is a good way to ensure it doesn't acquire a significance of its own beyond being just a transfer medium.

    If it were my personal problem, I'd definitely leave the repo on the stick.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  12. #12
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Mario F. View Post
    Ok. ermm...

    To be clear, if I clone the repo, make changes to the copy on the same branch and commit, I cannot push the changes to the origin? I'm getting:
    What origin? I thought you had three dev machines, each of which is equivalent. The "origin" is the "authoritative" respository. You claim you don't have one.

    Make sure you are distinguishing between the concept of the "remote" and the "origin." Your setup has no origin, but you are tracking various remotes.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  13. #13
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by phantomotap View Post
    O_o

    A protocol which asks that I delete a valuable backup is not a protocol to which I will agree.
    There are already four copies of the repo, how many more should we add? Another 15?

    Using "git" will ensure, hopefully, that you don't override good data with bad.
    To me this looks like a matter of policy, not a question about the reliability of a memory stick. If the policy is that the stick is just a sneakernet cable, then leaving the repo on the stick gives the wrong impression of the actual policy.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  14. #14
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Mario F.
    To be clear, if I clone the repo, make changes to the copy on the same branch and commit, I cannot push the changes to the origin? I'm getting:
    The error message means: you have a working tree in the destination repository and that could be problematic, so we're not letting you push unless you get rid of the working tree or insist that we allow the push anyway.

    A quick search brings up Git bare vs. non-bare repositories for your reading pleasure. There's an example towards the end of how you could initialise a bare repository, so you could try doing that on your USB stick. Alternatively, you could try the configuration options mentioned in the error message to proceed anyway.

    EDIT:
    Quote Originally Posted by brewbuck
    Because Mario said "I don't want to use the pen drive as a central repository either."

    Blowing it away is a good way to ensure it doesn't acquire a significance of its own beyond being just a transfer medium.
    Right, but that was stated "For the same reasons" as why Mario F. did not want to copy .git directories around. Since the reasons do not actually apply, I reasoned that this requirement does not necessarily apply either.

    Quote Originally Posted by brewbuck
    There are already four copies of the repo, how many more should we add? Another 15?
    There will always be one copy in the USB stick whenever it is not plugged into a computer.
    Last edited by laserlight; 02-18-2015 at 02:52 PM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #15
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    I read the file, thanks laserlight. The whole bloody terminology and workflow of this stupid tool (git) is giving me an headache.

    Look, I'll dig deeper into git later. This is just nonsense a waste of time. I need to get to work, not to struggle with this thing. I'll follow brewbuck advice for now, until I get a hang of git. He presents a much straightforward way to just get things done. I just need to keep my commits synced between the laptop while travelling, my computer at the office and my main development computer at home.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ssh to multiple machines via c program?
    By purest in forum Linux Programming
    Replies: 6
    Last Post: 12-12-2006, 11:25 AM
  2. drawing flow-charts for every single program??
    By LogicError in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 05-30-2005, 10:22 AM
  3. Single API for multiple CGI
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 10-09-2001, 06:31 AM
  4. changing from multiple-doc to single-doc
    By swordfish in forum C++ Programming
    Replies: 2
    Last Post: 08-31-2001, 07:52 PM