I have a network on computers all of which have access to the same git repository. This network will not have access to the internet and I'm trying to find a way to be able to update the git repositories on all computers. I can upload files to the computers and run shell commands on them, but I cannot simply run git pull origin master. So I've set up one of the computers as a "central" computer, and other computers to do a git pull central master to update themselves with the central computer. However, I'm trying to figure out what's the best way to update the central computer. I'm trying git patches, so I run a command to get the current commit ID on the central computer, and do a git diff <commitIDCentralComp> <commitIDGitHub> > patch_file.patch then upload that patch file and run a git apply patch_file.patch, and then run git pull central master on the other computers, but the problem with that is that even though it updates the code, the commit ID on the central computer does not change. So if I update the code on GitHub, and now have a different commit ID, I'll just be making a patch file with the original commit ID on the central computer, not the new one. Is there a way to ensure the commit ID changes as well and is in sync with the latest on GitHub?
git apply patch does not update commit id
164 views Asked by EmaadP At
1
There are 1 answers
Related Questions in GIT
- problem to push files on a repository git
- diff3 output in git conflict style, including mergeable hunks
- Git Not In Sync with Local Branch
- Setting up the version control of .dotfiles while the .config is connected to a forked repo
- How to fix overriding the main branch in Git?
- I can't add text to "Message" in VS Code when committing to Git
- How can i redirect pull request from main branch to another branch
- Xcode commits (possibly outside of any branch) disappeared, how to get them back?
- Git/TortoiseGit : how to apply ONLY the changes from ONE commit from branch A, to branch B?
- How can I reintroduce username an password on git using fedora?
- GIT SKIP EMPTY DIRECTORIES
- Git smudge run once per checkout or per commit?
- I can't find ~/.profile or ~/.bashrc in C:/Users/<user>/.ssh folder
- Set environment variable during push for GitHub Actions
- Android WebRTC compile
Related Questions in GITHUB
- How to update to the latest external Git in Azure Web App?
- Github Pages Deployment deploys a blank page
- Git Not In Sync with Local Branch
- How do I create a test passing badge for my yaml below
- Cant connect to any github repository from my netbeans 20
- How can i redirect pull request from main branch to another branch
- Trying to update the version.go file with the release tag from GitHub actions but its failing
- Encountering Errors Running GitHub Project: Wavelet-pixel domain progressive fusion network for underwater image enhancement - Seeking Assistance
- How can I reintroduce username an password on git using fedora?
- How do I find Github File_ID?
- Forking vs Cloning in GitHub
- I can't find ~/.profile or ~/.bashrc in C:/Users/<user>/.ssh folder
- how to build nextjs app unable to build and deploy
- Plugin with id 'com.android.application' not found in Github Winlator Project
- Git commit asks for passphrase which I don't remember
Related Questions in COMMIT
- Xcode commits (possibly outside of any branch) disappeared, how to get them back?
- VS Code suggest me to upload all my user Data to github
- GitHub Commits Showing Someone Else's Name (Incorrect Name)
- problem delete row in postgresql with commit
- Remove specific commit in Visual Studio 2022
- not able to add previous commit into github tag using workflow
- Github Commit not working as it has in the past
- How to get latest commit to be pulled for a PR?
- How to retrieve the number of commits of a Git branch without downloading full commit history
- in express how to execute a function (like db commit) only after successful response is sent?
- Seeking Advice on Syntax Validation for Bitbucket UI Commits
- Eclipse IDE can't Commit & Push to GitHub
- COMMIT within a PostgreSQL function fails
- Git how to commit changes in a specific tracked directory only and do not include other tracked directories/files in this commit
- Can I make Xcode switch to Project navigator after a Commit completes?
Related Questions in GIT-PATCH
- Git/TortoiseGit : how to apply ONLY the changes from ONE commit from branch A, to branch B?
- Git: clarifying doc for how "patch id" is computed and how it may relate to git diff:
- How to apply patches in git when multiple patches has some common changes?
- Gitlab - Commit hash doesn't match when create a commit through the Gitlab UI
- How to remove changes related to one file from patch
- git apply patch does not update commit id
- Error when trying to apply git diff, "No valid patches in input"
- How to create a git patch from the committed changes
- git apply is not respecting file renames using `git mv`
- Git apply patch to specific file outside of git repo
- how to see the file which would be committed
- Automerge after patch apply with conflics
- Is it possible to undo a `git add` and go to the exact same staging index as before?
- Create patch or diff file from git repository for target directory and apply it to another different git repository with different directory
- How to create a git patch with the parent SHA so it can serve as an archive?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
TL;DR
git bundleis the command you want to use for this task. It is precisely designed for the "offline" transfer of Git objects (to quote the manual), just like you want to do.git bundlecreates a file that contains pretty much the same stuff agit fetchwould download, that you can then copy over through whatever means you need to use.User manual: https://git-scm.com/docs/git-bundle
My
git bundleuse caseFor a few years I had a situation where I had two distinct "central" repositories on two networks that didn't talk to each other. I would create a bundle on one, carry it over to the other (through some maddeningly inefficient means, though that's besides the point), and incorporate the bundle there.
Most common case: copy a few commits from one server to the other
In my workflow, the most common case was that one server was ahead of the other and I had to copy a few commits over.
To illustrate, assume I had 3 commits to take from Host1 to Host2:
On Host1, in a sandbox cloned from the Host1 central server:
Copy
mybundleto Host2.On Host2, in a sandbox cloned from Host'2 central server:
Now when you look at the branches in your sandbox on Host2, you'll see
bundle-mainwhich points to the same commitmainpointed to on Host1. It actually took me a while to wrap my brain around thatgit fetchcommand: you're just treating the bundle as if it was a remote. And it sort-of it: it contains the stuff you would need to fetch from Host1's remote, but in a file instead of on an actual remote server.Once you've confirmed that
bundle-mainis the same commit asmainon Host1, mergebundle-mainintomainand push it to your Host2 central server:And now, Host1's
mainand Host2'smainshould be identical.What if the repos diverged between Host1 and Host2?
Now, with this workflow, I often found that someone had made changes on Host1 and someone else different changes on Host2, requiring a merge.
The workflow for this case is basically the same, with a small twist: when you do
git merge bundle-main, instead of a fast-forward merge like I assumed above, you'll create an actual merge commit. You can then take the merge commit created on Host2 back over to Host1 with exactly the same process, in the reversed direction.The general rule for creating the bundle
To be sure the bundle has everything needed on the other side, when you do
git bundle create mybundle <commit1>..<commit2>, you need to make sure<commit1>is a commit that actually exists on the destination server, and<commit2>is the new HEAD commit you want to send there. Out of paranoia, I typically went one or two commits further back than necessary because the file transfer between my two networks was painful and I didn't want to have to redo it, but you probably don't have to do that.Epilogue
Thankfully, I now have a Git server I can see from both networks, so I haven't actually used this workflow in a while. I hope I didn't get any details wrong, but if anything doesn't work let me know and I'll adjust my answer. I've tested my commands here just now, though, so they should work for you. Hopefully I didn't miss any important corner cases or details.