Author Topic: Using Github like it was rsync  (Read 3388 times)

0 Members and 1 Guest are viewing this topic.

Online 5U4GBTopic starter

  • Super Contributor
  • ***
  • Posts: 1830
  • Country: au
Using Github like it was rsync
« on: November 21, 2025, 01:42:23 am »
I help out with a Github project that (re)generates a lot of config files (YAML) offline that need to be posted to the repo.  Problem is that this doesn't follow the usual workflow of { pull, update, push } but is really an rsync-style operaton where changed/newer files are pushed to the repo.  So the required operation is { github repo with older files + local copy of updated/newer files -> github repo with updated/newer files }.

I assume there's some way to do this but I'm not having much luck finding it, Google searches are returning all sorts of stuff around using rsync and whatnot (I'm not looking to use rsync, just using it to illustrate the mode of operation), and some trial-and-error attempts at doing it have yielded less than satisfactory results.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Using Github like it was rsync
« Reply #1 on: November 21, 2025, 01:44:53 am »
Code: [Select]
git add .
git commit -m "latest changes"
git push origin
 

Online 5U4GBTopic starter

  • Super Contributor
  • ***
  • Posts: 1830
  • Country: au
Re: Using Github like it was rsync
« Reply #2 on: November 21, 2025, 01:57:49 am »
That was one of the things I tried initially and... something went wrong but it was a few months ago and I didn't take notes on what it was because I was trying all sorts of other things as well, let me try again.
 

Offline gnif

  • Administrator
  • *****
  • Posts: 1939
  • Country: au
  • Views and opinions are my own
Re: Using Github like it was rsync
« Reply #3 on: November 21, 2025, 02:07:55 am »
Code: [Select]
git add .
git commit -m "latest changes"
git push origin

Note that `git add .` will also add any new files in the path to the repository, if you only want to update existing without allowing random files to get added just use `git commit -a "latest changes"`
 

Offline paulca

  • Super Contributor
  • ***
  • Posts: 6641
  • Country: gb
Re: Using Github like it was rsync
« Reply #4 on: November 21, 2025, 11:25:54 am »
My gut reaction is... why are you putting derivatives into the repo in the first place?

I know there has to be a reason.

We generate a lot of code from yamls and yaml from templates, but they are always handled by the IDE and or build process.  Even to the point when you deploy the UI, it downloads the yamls and generates it's own stubs for Angular from them.  UI folks are weird though.  Backend the yamls are in a dependency which is pinned.  Its fetched, code and yamls generted, then the build runs.

I'm curious as to why you can't do this or if the output should be in git?
"What could possibly go wrong?"
Current Open Projects:  68000 Self Build computer + OS.
 

Offline paulca

  • Super Contributor
  • ***
  • Posts: 6641
  • Country: gb
Re: Using Github like it was rsync
« Reply #5 on: November 21, 2025, 11:37:06 am »
Note that `git add .` will also add any new files in the path to the repository, if you only want to update existing without allowing random files to get added just use `git commit -a "latest changes"`

I tend to teach git a bit more ...  disciplined than this. It's 100 times easier to make a git mistake than it is to fix it.

git status
git pull
git status

First and foremost, always.  If this doesn't work, gets blocked or causes a merge hell, fix it FIRST.

Add files specifically where practical.

git add -u
git status

This adds "known and modified" files to the staging.  running status lets git read back what you did and you to validate it didn't do something unexpected.... like add a whole bunch of build temp files.

git add src/main/blah.blah

git add src/main/newpackage/
git status
git reset src/main/newpackage/.garbage
echo '**/.garbage' >> .gitignore
git add .gitignore

git status

Your git status should be "clean".  The more crude and cruft you build up in your "untracked" file list that don't go away on a "make clean" the more risk you have you forget to commit something.

When you are happy that the "staging" in green looks like what you want to comit... 

git commit -m "TICKET_ID Blah blah something useful"
git pull
git push


The amount of crap you have to clean up when people just run stuff like:

git commit -a "Blah"
git commit .

Is formidable.  Then you end up with somone commiting a build temp file but with their UID and 600 perms.  Now nobody can build the app, not even the build servers.

A common mistake I see is not syncing the repos fully first.  I am guilty of it myself.  For a while I merge bombed myself multiple times.  Commit ticket branch.  Raise PR.  Merge PR.  Create new ticket branch.  Work on ticket branch.  Go to MR ticket branch and BOOM!  So you face plam yourself and merge the main branch back into pick up your first ticket changes.  Fixed?  Nope.  Your branch and the remote branch have the same code, same changes, but applied in a different order.  Your options are to "rebase" your local commits into a new order and fix any conflicts OR take a deep breath and push and let git sort it out.
« Last Edit: November 21, 2025, 11:45:04 am by paulca »
"What could possibly go wrong?"
Current Open Projects:  68000 Self Build computer + OS.
 
The following users thanked this post: pardo-bsso, Geoff-AU

Offline NE666

  • Frequent Contributor
  • **
  • Posts: 955
  • Country: gb
Re: Using Github like it was rsync
« Reply #6 on: November 21, 2025, 01:17:20 pm »
If you're new to Git/Github, I recommend starting here, rather than just jumping into a live repo: https://git-scm.com/book/en/v2

It's a free to download Apress book and maybe the best one available on this topic. You should read it cover to cover and work through the ideas being taught yourself on a test repo.

Because:

It's 100 times easier to make a git mistake than it is to fix it.


If you read Pro Git, you'll have a much greater understanding of not only how you should be working but also of the many things that can go wrong, and some of the solutions available to you WHEN they do.
 
The following users thanked this post: tooki

Offline paulca

  • Super Contributor
  • ***
  • Posts: 6641
  • Country: gb
Re: Using Github like it was rsync
« Reply #7 on: November 21, 2025, 02:37:30 pm »
The only issue with a document like that is its not designed to teach you how to use git.  It is designed to teach you what git does.  There is a difference.

It's like reading a manual for something like an MCU.  This tells you nothing of "how" you will use it for your tasks.  It just tells you the tool set you have.

Things like cherry pick, rebase or revert should be avoided as much as possible.  They shouldn't be treated as standard processes.  Unless you have a VERY busy repo the need to rebase is usually a sign of poor branch hygene and not pulling in parent changes often enough.

Don't start me on "fork".  I have seen teams run models where every member had their own fork of all branches locally.  Forks were merge fested into "Golden forks" in big meetings.  Horrible.

What I often say is:  "Just because the tool exists does not mean you must use it.  Stop looking for ways to complicate things just so you get to play with the tools on the top shelf!"  You usually only need them if you broke something with the tools on the middle shelf.

In the professional world git patterns change like the weather and usually it's a mandated change put upon you rather than your choice.  In my current team they use branch prefixes for deployments.  1:1 mappings.  It's lots of fun.

Other times your pipelines, CI/CD flows and git "front end" usage and reporting have a say in your branch strategy and naming. 

If you get to pick from a grassy green field...  start simple.

IF you want something more defined and supported, but simple enough and can be taking in parts or the whole.  "Git Flow" - either Atlasian style or one of the popularly blogged deriviatives.
"What could possibly go wrong?"
Current Open Projects:  68000 Self Build computer + OS.
 
The following users thanked this post: 5U4GB

Offline paulca

  • Super Contributor
  • ***
  • Posts: 6641
  • Country: gb
Re: Using Github like it was rsync
« Reply #8 on: November 21, 2025, 03:35:47 pm »
Personally I think the best way to start using git is to install it and use it.

Git bash for windows.  Just git and a terminal for Linux.

If you cd into your project folder and type:

Code: [Select]
git init
You have made a git repo.  With a master branch.  You can commit and do all the wonderful things.

The next step usually needed is to access that from somewhere else.  Like to be able to access it from a server OR from your IDE for example.  For that, git basically just wears ssh as a coat.

Consider this is how I create my "home", "hobby" repos:
2702553-0

The difference but similarity between a local and a remote repo is that git doesn't care.  Repositories are a multitude.  It is only by convention that one repo "pushes" or "pulls" from another.  It could equally easily pull or push to another repo entirely.

For people used to SVN or CVS who might be a bit battle torn from branches might roll their eyes when git tells them "everything is a branch.  Not only that, but everything is a distributed branch with multiple far flung copies in many states of "out-of-date" all existing together in harmony.  To old school CVS admins this sounds like they have arrived in hell.  However.  The genuis is that is actually works!  Can be as confusing as it sounds when it wants to be, but this is why we follow best practices and published flows to avoid treading on the dragons tail.
"What could possibly go wrong?"
Current Open Projects:  68000 Self Build computer + OS.
 

Offline NE666

  • Frequent Contributor
  • **
  • Posts: 955
  • Country: gb
Re: Using Github like it was rsync
« Reply #9 on: November 21, 2025, 03:41:23 pm »
It is designed to teach you what git does.  There is a difference.

I agree. And sometimes, knowing how a particular tool or feature actually works and what it's side effects are, is the best disincentive to actually using it, leading to a better 'how'.
 

Offline paulca

  • Super Contributor
  • ***
  • Posts: 6641
  • Country: gb
Re: Using Github like it was rsync
« Reply #10 on: November 21, 2025, 03:45:56 pm »
It is designed to teach you what git does.  There is a difference.

I agree. And sometimes, knowing how a particular tool or feature actually works and what it's side effects are, is the best disincentive to actually using it, leading to a better 'how'.

I hold an entirely practicalist view point on it.  I like to take the sharp tools off the table before people get to cut each other with them :)
"What could possibly go wrong?"
Current Open Projects:  68000 Self Build computer + OS.
 
The following users thanked this post: pardo-bsso, SteveThackery

Offline gnif

  • Administrator
  • *****
  • Posts: 1939
  • Country: au
  • Views and opinions are my own
Re: Using Github like it was rsync
« Reply #11 on: November 22, 2025, 01:01:15 am »
Note that `git add .` will also add any new files in the path to the repository, if you only want to update existing without allowing random files to get added just use `git commit -a "latest changes"`

I tend to teach git a bit more ...  disciplined than this. It's 100 times easier to make a git mistake than it is to fix it.

git status
git pull
git status

First and foremost, always.  If this doesn't work, gets blocked or causes a merge hell, fix it FIRST.

Add files specifically where practical.

git add -u
git status

This adds "known and modified" files to the staging.  running status lets git read back what you did and you to validate it didn't do something unexpected.... like add a whole bunch of build temp files.

git add src/main/blah.blah

git add src/main/newpackage/
git status
git reset src/main/newpackage/.garbage
echo '**/.garbage' >> .gitignore
git add .gitignore

git status

Your git status should be "clean".  The more crude and cruft you build up in your "untracked" file list that don't go away on a "make clean" the more risk you have you forget to commit something.

When you are happy that the "staging" in green looks like what you want to comit... 

git commit -m "TICKET_ID Blah blah something useful"
git pull
git push


The amount of crap you have to clean up when people just run stuff like:

git commit -a "Blah"
git commit .

Is formidable.  Then you end up with somone commiting a build temp file but with their UID and 600 perms.  Now nobody can build the app, not even the build servers.

A common mistake I see is not syncing the repos fully first.  I am guilty of it myself.  For a while I merge bombed myself multiple times.  Commit ticket branch.  Raise PR.  Merge PR.  Create new ticket branch.  Work on ticket branch.  Go to MR ticket branch and BOOM!  So you face plam yourself and merge the main branch back into pick up your first ticket changes.  Fixed?  Nope.  Your branch and the remote branch have the same code, same changes, but applied in a different order.  Your options are to "rebase" your local commits into a new order and fix any conflicts OR take a deep breath and push and let git sort it out.

I completely agree with much of this, my goto is:
Code: [Select]
git commit -p

This lets you review each patch, edit/accept/reject them, etc. Very handy for spot checking for errors before pushing, or splitting cosmetic changes out into a separate commit

And yes, `status` and manual `add` too.

As for contributing, I hate merges, they are rarely needed and I prefer to always rebase

Code: [Select]
git fetch upstream
git rebase upstream/origin
git push

Generally I will also use an interactive rebase to cleanup my commits, re-order them, squash the ones that can be merged into a prior commit (ie bug fix a prior not yet up-streamed commit I made)

Code: [Select]
git log # get the hash of the commit you want to start rebasing from
git rebase -i <hash>
« Last Edit: November 22, 2025, 01:06:33 am by gnif »
 

Offline paulca

  • Super Contributor
  • ***
  • Posts: 6641
  • Country: gb
Re: Using Github like it was rsync
« Reply #12 on: November 22, 2025, 12:21:48 pm »
I never found a need for rebase to be honest.  I'm not even sure you could rebase a main branch as they are FF only. 

The "Fast forward only" setting means you cannot rewrite what has been rewitten.  You can add more commits, but you can't change whats already there.

You could rebase your own dev branch before raising the PR.  However our PR merge process is to "Squash and delete", so it would just get squashed out anyway and the history is deleted.  Squash as in the merge is a single commit.  The PR'd branch is only deleted on the remote of course, if the ticket does come back to you for some reaosn, you can just repush the local.
"What could possibly go wrong?"
Current Open Projects:  68000 Self Build computer + OS.
 

Offline gnif

  • Administrator
  • *****
  • Posts: 1939
  • Country: au
  • Views and opinions are my own
Re: Using Github like it was rsync
« Reply #13 on: November 23, 2025, 05:48:23 am »
I never found a need for rebase to be honest.  I'm not even sure you could rebase a main branch as they are FF only. 

The "Fast forward only" setting means you cannot rewrite what has been rewitten.  You can add more commits, but you can't change whats already there.

You could rebase your own dev branch before raising the PR.  However our PR merge process is to "Squash and delete", so it would just get squashed out anyway and the history is deleted.  Squash as in the merge is a single commit.  The PR'd branch is only deleted on the remote of course, if the ticket does come back to you for some reaosn, you can just repush the local.

No, not rebase the main branch, rebase your local branch on the main branch before making a PR (or allowing a push), disable merges on the main repository so that all changes must be applied clean on top of the tree. If the main branch moves and the PR can no longer be applied to the main branch, then the PR author needs to rebase again. Put the conflict resolution responsibility on the author of the changes rather then the upstream maintainer. The author of the new code is best suited to fix any conflicts anyway because it's their code.

For example, you can configure a GitHub repository like this:


This results in a very clean commit history that is easy for everyone to follow and easy to bisect to debug if needed.
« Last Edit: November 23, 2025, 05:56:11 am by gnif »
 

Online 5U4GBTopic starter

  • Super Contributor
  • ***
  • Posts: 1830
  • Country: au
Re: Using Github like it was rsync
« Reply #14 on: November 25, 2025, 01:26:54 am »
I'm curious as to why you can't do this or if the output should be in git?

The data is coming from a system that's only accessible via an SSH jump host and only updated sporadically from further sources, it doesn't fit into the standard Git workflow.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Using Github like it was rsync
« Reply #15 on: November 25, 2025, 01:29:18 am »
I'm curious as to why you can't do this or if the output should be in git?

The data is coming from a system that's only accessible via an SSH jump host and only updated sporadically from further sources, it doesn't fit into the standard Git workflow.

The second sentence does not logically follow from the first sentence.
 
The following users thanked this post: abeyer

Online 5U4GBTopic starter

  • Super Contributor
  • ***
  • Posts: 1830
  • Country: au
Re: Using Github like it was rsync
« Reply #16 on: November 25, 2025, 01:31:59 am »
The only issue with a document like that is its not designed to teach you how to use git.  It is designed to teach you what git does.  There is a difference.

Some other Git book I've read, can't remember the title any more, also didn't really teach you how to use Git.  It taught you how to reinvent your entire world in Git, but not "if all you want to do is this then do these things".  It felt like I was being encouraged to join a cult.

In general though I just use Git like most other people do.
« Last Edit: November 25, 2025, 01:37:27 am by 5U4GB »
 

Online 5U4GBTopic starter

  • Super Contributor
  • ***
  • Posts: 1830
  • Country: au
Re: Using Github like it was rsync
« Reply #17 on: November 25, 2025, 01:39:24 am »
I'm curious as to why you can't do this or if the output should be in git?

The data is coming from a system that's only accessible via an SSH jump host and only updated sporadically from further sources, it doesn't fit into the standard Git workflow.

The second sentence does not logically follow from the first sentence.

The OP asked a question about integrating Git with the IDE and build process, I explained that neither of those exist.
 

Offline abeyer

  • Frequent Contributor
  • **
  • Posts: 976
  • Country: us
Re: Using Github like it was rsync
« Reply #18 on: November 25, 2025, 02:33:40 am »
The OP asked a question about integrating Git with the IDE and build process, I explained that neither of those exist.

I'm not sure that was really the point... the real question was the first line, why are you putting outputs in git? The typical model is to put inputs only, aka the files being created/edited by humans and not systems. That's not a hard and fast rule, but going against it is less common...and the typically suggested approach would be to put the source data that's used to generate the config files into git instead.

 
The following users thanked this post: Someone

Online 5U4GBTopic starter

  • Super Contributor
  • ***
  • Posts: 1830
  • Country: au
Re: Using Github like it was rsync
« Reply #19 on: January 12, 2026, 10:04:35 am »
git status
git pull
git status

First and foremost, always.  If this doesn't work, gets blocked or causes a merge hell, fix it FIRST.

Add files specifically where practical.

git add -u
git status

This adds "known and modified" files to the staging.  running status lets git read back what you did and you to validate it didn't do something unexpected.... like add a whole bunch of build temp files.

git add src/main/blah.blah

git add src/main/newpackage/
git status
git reset src/main/newpackage/.garbage
echo '**/.garbage' >> .gitignore
git add .gitignore

git status

Your git status should be "clean".  The more crude and cruft you build up in your "untracked" file list that don't go away on a "make clean" the more risk you have you forget to commit something.

When you are happy that the "staging" in green looks like what you want to comit... 

git commit -m "TICKET_ID Blah blah something useful"
git pull
git push

I played with this for quite some time at the time and each time ended up in a github maze with suggestions from the software which, when followed, just led to a different part of the maze, and then other things came up and I had to put it on hold... starting again from scratch, with the required init/config setup done and trying to update a sample file test.txt already in the remote repo with a newer copy, what I've found works is:

Quote
# Fetch a copy from the remote and make sure all is OK.

git status
git pull origin main
git status

# Add files and read back what was done.
#   -n = Dry run, don't make changes.
#   -u = Update, only add modified files.
#   -A = All, add all files.
#   -i = Interactive, prompt for each file.

cp ~/test.txt .
git add .
git status

# Commit changes.  The pull makes sure source and dest are in sync, the push
# actually performs the update.

git commit -m "Test file update"
git pull
git push --set-upstream origin main
« Last Edit: January 12, 2026, 10:08:35 am by 5U4GB »
 

Offline Geoff-AU

  • Frequent Contributor
  • **
  • Posts: 429
  • Country: au
Re: Using Github like it was rsync
« Reply #20 on: January 13, 2026, 01:03:09 am »
I completely agree with much of this, my goto is:
Code: [Select]
git commit -p

This lets you review each patch, edit/accept/reject them, etc. Very handy for spot checking for errors before pushing, or splitting cosmetic changes out into a separate commit

Ooh nice tip.  I've never used cherry-pick because I'm working on small repos but this is cherry-picking for lines in each file which is something I do use relatively often (eg I might want to commit functionality changes but leave my hacky debugging prints in the working tree until I'm done messing with stuff).
 

Online John Coloccia

  • Super Contributor
  • ***
  • Posts: 1636
  • Country: us
Re: Using Github like it was rsync
« Reply #21 on: January 16, 2026, 02:37:10 am »
As an aside, I don't get the urge to squash, rebase, etc to get some sort of "clean" commit.

Ultimately, you're probably going into some sort of dev branch anyway....or if you're doing continuous delivery, your delivery branch.

If you just want to see the merged commits on that branch, git log --first-parent.  It's an important enough concept that there's an actual switch for it. Why loose the development history? If you don't want to look at it, don't. If you do, then you can.
 

Offline paulca

  • Super Contributor
  • ***
  • Posts: 6641
  • Country: gb
Re: Using Github like it was rsync
« Reply #22 on: January 16, 2026, 09:06:20 am »
As an aside, I don't get the urge to squash, rebase, etc to get some sort of "clean" commit.

Ultimately, you're probably going into some sort of dev branch anyway....or if you're doing continuous delivery, your delivery branch.

If you just want to see the merged commits on that branch, git log --first-parent.  It's an important enough concept that there's an actual switch for it. Why loose the development history? If you don't want to look at it, don't. If you do, then you can.

This.  Rebase and cherry pick are last resorts.  Some people seem to prefer that they put their chances after the incoming remote changes.

However, in 99% of repos the developers commit will be squashed into a merge commit anyway and the history within it deleted with the branch once the PR/MR is accepted.

The main/dev branch will just show things like:

Merge feature/ABC-1234
Merge feature/ABC-1235
Merge feature/ABC-1236
"What could possibly go wrong?"
Current Open Projects:  68000 Self Build computer + OS.
 

Offline paulca

  • Super Contributor
  • ***
  • Posts: 6641
  • Country: gb
Re: Using Github like it was rsync
« Reply #23 on: January 17, 2026, 12:57:41 pm »
Interesting video. 

The majority of my project experience has been with GitFlow or GitFlow-like strategies.  Mostly for the reasons she states in the video.  Strict versioning, approvals required, DevOps and deployments are different teams with approvals require to deploy/release.

"What could possibly go wrong?"
Current Open Projects:  68000 Self Build computer + OS.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->