This guide provides clear instructions for setting up Git repositories, configuring remote access, synchronizing changes, and collaborating effectively. Follow each section carefully to ensure a smooth workflow and minimize conflicts.
Clone the primary GitLab repository to your local machine to start working on the project.
git clone https://baltig.polito.it/caos2024/group2.git
To enable backups and multi-location redundancy, add the GitHub repository as a remote:
git remote add github https://github.com/neo-CAOS/group2.git
Verify that both GitLab and GitHub repositories are configured correctly:
git remote -v
You should see output similar to this:
github https://github.com/neo-CAOS/group2.git (fetch)
github https://github.com/neo-CAOS/group2.git (push)
origin https://baltig.polito.it/caos2024/group2.git (fetch)
origin https://baltig.polito.it/caos2024/group2.git (push)
The project includes a single script, sync.sh, to handle both pull and push operations. This ensures consistency and minimizes errors.
Before using the script, make it executable:
chmod +x sync.sh
-
Pull Updates:
Run the script with
pull
to fetch and integrate the latest changes:./sync.sh pull
-
Push Changes:
Run the script with push to synchronize your local changes with both GitLab and GitHub:
./sync.sh push
Note: The script checks for branch consistency, ensures local and remote synchronization, and prompts for a commit message during pushes.
-
Start by Pulling Updates: Always pull the latest changes before making modifications:
./sync.sh pull
-
Work on Modifications: Make your changes locally, ensuring they are well-documented and isolated.
-
Pull Again After Changes: Before pushing, pull again to incorporate any updates made by collaborators:
./sync.sh pull
-
Push Changes: Once your modifications are complete and conflicts (if any) are resolved, push the changes:
./sync.sh push
-
Coordinate with Team Members: Avoid working on the same files simultaneously to minimize conflicts.
-
Branch Mismatch: If you are not on the
main
branch, the script will prompt you to switch:git checkout main
-
Synchronization Issues: If local and remote branches are not synchronized, the script will notify you to pull updates before pushing.
In case of conflicts:
-
Manually resolve conflicts in affected files.
-
Stage the resolved changes:
git add <file>
-
Complete the merge process:
git commit
-
Run the synchronization script again:
./sync.sh push