Walkthrough: Working in multiple locations (HPC and Laptop) with Git. #110

Open
opened 2025-09-15 11:54:36 +00:00 by mahesh-panchal · 5 comments
mahesh-panchal commented 2025-09-15 11:54:36 +00:00 (Migrated from github.com)
  • How to sync your repo's to Github (using git remote)
  • How to rsync your files from HPC and laptop and vice-versa.
  • Why is this better than SSH into your HPC repo - separation of concerns.
- How to sync your repo's to Github (using `git remote`) - How to rsync your files from HPC and laptop and vice-versa. - Why is this better than SSH into your HPC repo - separation of concerns.
camcl commented 2025-10-22 15:36:03 +00:00 (Migrated from github.com)

Would this cover a case of triangular workflow, for instance when there is a "dubious ownership" issue but some local changes must still be pushed?

Would this cover a case of triangular workflow, for instance when there is a "dubious ownership" issue but some local changes must still be pushed?
mahesh-panchal commented 2025-10-23 07:06:52 +00:00 (Migrated from github.com)

Hi. I don't understand what's meant by dubious ownership. Do you mean you have two different Github/git users?
The idea was to cover data organization in a project based way, using git to track code but not data, and demonstrating how to leverage git plus a command runner to transfer data between HPC and laptop.

Can you clarify what you mean in your example? User1 makes changes at laptop and then ?

Hi. I don't understand what's meant by dubious ownership. Do you mean you have two different Github/git users? The idea was to cover data organization in a project based way, using git to track code but not data, and demonstrating how to leverage git plus a command runner to transfer data between HPC and laptop. Can you clarify what you mean in your example? User1 makes changes at laptop and then ?
camcl commented 2025-10-23 07:29:56 +00:00 (Migrated from github.com)

Sorry for having been unclear. I have faced this ownership issue when having to edit a git repository owned by a virtual user of our automation system. This repository was cloned by the virtual user on our HPC system. If I (as camcl user) would change the code in the HPC-local repository and commit the changes, then I would get an error message of "dubious ownership" upon attempting pushing my changes. Eventually, I had to clone again somewhere else on the HPC system the HPC-local clone. The second clone was owned by my myself, I added the github repo as a remote and could push my changes from the HPC-local clone nr. 2 to the gihub remote repo. So I ended up with a triangular system: HPC-local 1 --> HPC-local 2 --> github --> HPC-local 1. This setup is still somewhat unclear to me and I would be happy to get a walkthrough about a similar setup with someone who has more experience of this.

Sorry for having been unclear. I have faced this ownership issue when having to edit a git repository owned by a virtual user of our automation system. This repository was cloned by the virtual user on our HPC system. If I (as camcl user) would change the code in the HPC-local repository and commit the changes, then I would get an error message of "dubious ownership" upon attempting pushing my changes. Eventually, I had to clone again somewhere else on the HPC system the HPC-local clone. The second clone was owned by my myself, I added the github repo as a remote and could push my changes from the HPC-local clone nr. 2 to the gihub remote repo. So I ended up with a triangular system: HPC-local 1 --> HPC-local 2 --> github --> HPC-local 1. This setup is still somewhat unclear to me and I would be happy to get a walkthrough about a similar setup with someone who has more experience of this.
mahesh-panchal commented 2025-10-23 07:49:49 +00:00 (Migrated from github.com)

I've never encountered this, but I can look into it.

I've never encountered this, but I can look into it.
mahesh-panchal commented 2025-10-23 09:44:24 +00:00 (Migrated from github.com)

So I had a look into this.
Creating a separate clone is apparently the safe and recommended way of dealing with your scenario. When another user checks out a repo, it's owned by them, and doesn't allow (generally) for other users to commit to another users repo because it's a security risk. The .git folder also contains configuration, and potentially executable code that could run when you commit into that repo, so git doesn't allow the commit by another user by default ( for example, if a user gets compromised ). If you're happy to trust the repo, in your config you can do:

git config --global --add safe.directory /path/to/HPC-local-1

but be aware if there are pre-commit hooks or other things that can execute on your user info.
There's also a more complex way with user groups and git config core.sharedRepository group stuff (https://serverfault.com/questions/26954/how-do-i-share-a-git-repository-with-multiple-users-on-a-machine).

So I had a look into this. Creating a separate clone is apparently the safe and recommended way of dealing with your scenario. When another user checks out a repo, it's owned by them, and doesn't allow (generally) for other users to commit to another users repo because it's a security risk. The `.git` folder also contains configuration, and potentially executable code that could run when you commit into that repo, so git doesn't allow the commit by another user by default ( for example, if a user gets compromised ). If you're happy to trust the repo, in your config you can do: ``` git config --global --add safe.directory /path/to/HPC-local-1 ``` but be aware if there are pre-commit hooks or other things that can execute on your user info. There's also a more complex way with user groups and `git config core.sharedRepository group` stuff (https://serverfault.com/questions/26954/how-do-i-share-a-git-repository-with-multiple-users-on-a-machine).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
NBIS/Training-Tech-shorts#110
No description provided.