olliecampbell
Posts: 13
Joined: Sat Sep 29, 2018 10:40 am

A Github question maybe?

Wed Apr 24, 2019 1:54 pm

Hello,

I was wondering if you were able to apply some of your great experience with some suggestions on my programming setup at the moment. I'm a 1 man band and here's how I work at the moment:


Work computer: Github + Atom
Home computer: Github + Atom
Raspberry Pi's: Github


All of the above are synced to the same github repository. I only really use github at the moment as a way of tracking my changes and an easy way to transfer the code across machines.

I always run into problems with conflicts, as expected, when moving across machines to code.


i.e. I work away at work pushing changes to Github and pulling them down to my Raspberry Pis to test and adjust the code as I go. If I need to I'll then shutdown the Pi's, carry them home and carry on working on my Home laptop.

Here's the problems I get:

Each time I make a change to the code from my Work laptop I have to 'reset' the repository on my Pi's as they complain about merge conflicts. I do this with the following:

Code: Select all

 git pull origin/master; git reset --hard master/origin; git pull origin/master; my_script_that_I_want_to_test
The second one, when I move to my Home laptop I struggle to get Atom to pull down any new changes and ignore any local changes. I'm not sure where these changes are happening as I make sure I do a 'push' before closing it down on both my Work and Home laptops.

I've thought about cutting out Github and using a file sharing sync tool, but we use Google Drive at work and I believe that there isn't a Linux friendly version for it.

Is there something simple I'm missing or another way that I can do this?

Thanks

User avatar
topguy
Posts: 5489
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: A Github question maybe?

Wed Apr 24, 2019 3:29 pm

I'm definitly not a Git expert but it definitely sounds like you are doing something wrong.
I'm guessing a more experienced Git user would like to see both the errors you get and also a link to your github repository.

( I have a feeling you have committed files that should not be part of the repo, files created when building your project that is not really source-code )

olliecampbell
Posts: 13
Joined: Sat Sep 29, 2018 10:40 am

Re: A Github question maybe?

Fri Apr 26, 2019 12:29 pm

The errors are (and I'll pop back later with examples) just the standard merge conflict errors.

Heater
Posts: 12190
Joined: Tue Jul 17, 2012 3:02 pm

Re: A Github question maybe?

Fri Apr 26, 2019 7:31 pm

olliecampbell,
I only really use github at the moment as a way of tracking my changes...
You are doing right. That is what git is for. With or without github.
... and an easy way to transfer the code across machines.
I do this all the time.

Write a program on a PC. Push to github. Pull from github to Pi. Run it there, hack it there. Push back to github. Pull to PC and work on it some more. And around and around.

But here is the problem:

One pulls from github and hacks the code on a PC.
Before pushing from PC to github, one pulls the code from github to a Pi, one hacks the code on the Pi.

At this point PC and Pi have different versions of the code. Potentially with changes to the same files. The same lines of the same files.

Clearly if that is ever to be put back to github there will be merge conflicts. Which changes do you want to keep. Git cannot know.

OK, so perhaps one now pushes the code from PC to github. And then tries to push those different changes from the Pi. Oops, merge conflict. Actually I don't think it will let you do that.

So one tries to pull that latest code from githhub to Pi. Oops merge conflict. Of course. You just have to deal with the conflicts.

The way to avoid all this is to always push the changes you have made on one machine when you are done. Then on the other machine always pull that latest version before making any new changes. Again, when you are done push them to github.

That is to say, do lumps of work completely on one machine, pull, edit, push, before moving to the other machine. That is to say, always keep github up to date and always ensure your local copy is up to date before editing it.

If you follow that simple procedure you will never be facing merge conflict problems.

If you really need different changes on different machines, whilst developing an experimental feature say, then you will have to learn how to work with branches in git.

LdB
Posts: 1104
Joined: Wed Dec 07, 2016 2:29 pm

Re: A Github question maybe?

Sat Apr 27, 2019 4:15 am

I have the same issues with GitHub Ollie I work on multiple machines and I am always getting out of sync. Even the act of changing the code on your machine but editing the readme.md file out of github will put you in that situation. Usually I just end up frustrated and use the force option to sync which breaks all your GITHUB history but that is lesser of two evils for me. The way heater describes is the only way it works and I just can not guarantee that I can work like that so I am like Github histories worst enemy and I just trash it willingly.

Fortunately I don't require github at all for my own history which Visual Studio does but it is only available in the paid version of the product. I used to use CVS which was free and does all you to apply multiple differences both ways between repositories. That may be an option you might like to look at and there are plenty of tutorials on CVS on the net.

Rabbit_Pi
Posts: 23
Joined: Fri Sep 23, 2016 3:03 am

Re: A Github question maybe?

Sat Apr 27, 2019 11:35 pm

Interesting read.... I was about to show off my little app I made for new people to the PI to make git clones easier for them...basically cutting out the user terminal work for it. I was wondering how I could expand on it a bit more in its functionality and I saw this thread.

I named it "RuGit" the Ruby Git Clone application.(downloader whatever you want to call it) Its simple in its design and I even wanted the Install to be plug and play, so I took it out of the project folder, updated it to have paste functions via right click or ctrl+v, then made a Install script for it. It writes all of the directories and files, even makes a .desktop file to run it from the start menu. It is all GUI, with no terminal work for the user. You just add what directory you want, it even detects the /home/(user)(pi)/ of the system, paste the github link and push the button.

google drive download link: https://drive.google.com/open?id=1K3feN ... YvzL2SPQhk

Git Clone Link:https://github.com/CufeHaco/RuGit_Installer.git

There are the links if you want to try it out. If you do alot of git clones it does save alot of time. If you do use it, the Installer is still in Beta, so make sure its in your /home/usr(pi)/ dir when you run it. and if you want to uninstall it just run the installer again and it will uninstall. RuGit will work on any Debian Distro, Raspbian, Ubuntu, Mint, etc. however i haven't made it to work on arch Linux yet. Like I said It came to life on a Pi and made for raspbian beginners.

Again you Peaked my Interest. I wonder If i develop it more, letting you log in and out of GitHub, push new commits and repositories, or even use it as a place holder to hold your code to allow you to pick up on another device before making a repository for it, etc. would be handy for heavy GitHub users?

Return to “General programming discussion”