Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Git Sync Deleting Files and Folders, Optimize the Initialize Process, Make sparse checkout optional #229

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

hdwebpros
Copy link

@hdwebpros hdwebpros commented Jul 24, 2023

Addressing #228 and subsequently #213 and possible #222

Also note that sparse checkout has been flaky at best for the 50+ sites that we have tried it on. We developed a better init process and don't recommend it.

Improved Initialization Process for the Plugin

The new initialization process for the plugin has been designed to be more robust and handle the local file state and the repository more efficiently. Below is an overview of the key steps involved:

Check Git Initialization: The process begins by checking if Git is already initialized in the current directory. If not, it proceeds with the initialization steps.

Setup Branches: It determines the branches to be used by fetching the remote branch configuration and setting up a local branch accordingly.

Initialize Git Repository:

  • The .git folder is created using the init command.
  • The remote repository (upstream) is added.
  • The appropriate local branch is checked out.

Fetch and Integrate Changes:

  • Fetch updates from the upstream.
  • Backup untracked files locally to avoid losing them during the merge.
  • Merge changes from the upstream into the local branch.
  • Restore the backed-up untracked files, handling potential conflicts carefully.

Commit and Push:
The updates, along with any new files, are added and committed to the local repository with a predefined commit message.
This initial commit is then pushed to the upstream repository.

Sparse Checkout (Optional): If the 'sparse_checkout' configuration is set, this feature is enabled for the repository, allowing partial checkouts of the repository.

Handle Authentication: If needed, the process also includes authenticated access to the remote repository. Credentials are securely retrieved and used to update the remote URL.

Backup and Restore Untracked Files: Untracked files are safely backed up before the merge and restored after the merge process, ensuring no local changes are lost.

Rsync for File Synchronization: The rsync command is used to synchronize the directories while restoring untracked files, ensuring a reliable and efficient restoration process.

Clean Up: After the restoration of untracked files, the backup directory is cleanly removed to avoid clutter and potential conflicts in the future.

This enhanced initialization process aims to streamline the setup and synchronization of the local repository with the remote one, while ensuring that local changes are not overwritten or lost during updates. It makes the plugin more user-friendly and resilient to various repository states and configurations.

@hdwebpros hdwebpros changed the title Make sparse checkout optional Fix Git Sync Deleting Files and Folders, Optimize the Initialize Process, Make sparse checkout optional Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant