{
    "url": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten",
    "locale": "en",
    "title": "Git: branches, rebase and merge conflicts · DeLaParra Services",
    "description": "Working with feature branches, the difference between ‘merge’ and ‘rebase’, resolving a merge conflict in VS Code, and worktrees for AI assistants.",
    "alternates": {
        "en": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten",
        "nl": "https://delaparra-services.nl/nl/handleidingen/git-branches-rebase-en-merge-conflicten"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.csv",
        "md": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.md",
        "json": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.json",
        "zip": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.zip",
        "pdf": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.csv",
            "encodingFormat": "text/csv",
            "name": "git-branches-rebase-en-merge-conflicten.csv"
        },
        {
            "url": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.json",
            "encodingFormat": "application/json",
            "name": "git-branches-rebase-en-merge-conflicten.json"
        },
        {
            "url": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.md",
            "encodingFormat": "text/markdown",
            "name": "git-branches-rebase-en-merge-conflicten.md"
        },
        {
            "url": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.pdf",
            "encodingFormat": "application/pdf",
            "name": "git-branches-rebase-en-merge-conflicten.pdf"
        },
        {
            "url": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.zip",
            "encodingFormat": "application/zip",
            "name": "git-branches-rebase-en-merge-conflicten.zip"
        }
    ],
    "markdown": "# Git: branches, rebase and merge conflicts\n\nThis guide builds on *Working with Git*. You already know how `commit`, `push` and `pull` work. Now you’ll learn how to work safely with multiple changes at the same time.\n\n## Working with a branch\n\nA **branch** is a separate branch where you can try things out without affecting the main version (`main`).\n\n```bash\ngit switch main\ngit pull                      # eerst de nieuwste versie ophalen\ngit switch -c feature/factuur-pdf\n# ... werken en committen ...\ngit push -u origin feature/factuur-pdf\n```\n\nNext, open a **pull request** on GitHub. This allows someone (or a reviewer) to review your changes before they are merged into `main`.\n\nUse clear names: `feature/...` for new features, `fix/...` for fixes.\n\n## Merge or rebase?\n\nWhilst you’re working, `main` also changes. There are two ways to incorporate those changes into your branch:\n\n| | `git merge main` | `git rebase main` |\n|---|---|---|\n| What happens | An extra \"merge commit\" is added | Your commits are merged back into `main` |\n| History | Shows exactly what happened | Clear and well-organised |\n| Risk | Low | Rewrites history |\n\n**Rule of thumb:** only rebase a branch that you are the only one working on. Never rebase `main` or a branch that others are using.\n\n```bash\ngit switch feature/factuur-pdf\ngit fetch origin\ngit rebase origin/main\ngit push --force-with-lease\n```\n\nAfter a rebase, you must push using `--force-with-lease`. This is the safe version of `--force`: it will refuse if someone else has pushed something in the meantime.\n\nIf something goes wrong during a rebase, `git rebase --abort` will restore everything to how it was.\n\n## Resolving a merge conflict\n\nA conflict arises when you and someone else have both changed the same rules. Git then cannot determine which version is correct. In the file, you will see:\n\n```\n<<<<<<< HEAD\n$prijs = $bedrag * 1.21;\n=======\n$prijs = $bedrag * $btw;\n>>>>>>> feature/btw-instelling\n```\n\nIn **VS Code**, buttons appear above the conflict: *Accept Current*, *Accept Incoming*, *Accept Both*. Choose the correct version, or edit the code manually to ensure it is correct. Then:\n\n```bash\ngit add bestand.php\ngit rebase --continue    # of: git commit (bij een merge)\n```\n\nAlways test your app after a conflict. Feel free to ask your AI assistant to explain the conflict, but check what it chooses.\n\n## Good commit messages\n\nWrite, in the imperative, what the commit does:\n\n```\nfeat(facturen): voeg PDF-download toe\nfix(checkout): voorkom dubbele betaling bij herhaalde webhook\n```\n\nMany teams add an emoji at the start, such as ✨ for ‘new’ or 🐛 for a ‘fix’. The **conventional-commit** and **gitmoji-status-commits** skills allow your assistant to do this consistently. See also *Commit messages and status emojis*.\n\n## Worktrees: multiple sectors at the same time\n\nWith a **work tree**, you can have two branches open at the same time in separate folders. This is handy if your AI assistant is working on a feature whilst you’re fixing a bug:\n\n```bash\ngit worktree add ../mijnapp-fix fix/login-bug\n# klaar:\ngit worktree remove ../mijnapp-fix\n```\n\n## Useful commands\n\n| Command | What it does |\n|---|---|\n| `git log --oneline --graph` | History as a tree |\n| `git stash` / `git stash pop` | Temporarily stash / restore changes |\n| `git cherry-pick <hash>` | Pick a single commit from another branch |\n| `git revert <hash>` | Undo a commit with a new commit (safe) |\n| `git bisect` | Find the commit that caused a bug |\n\nBe careful with `git reset --hard`: it will discard your uncommitted work.\n\n## Need help?\n\nWould you like every pull request from you or your agent to be reviewed before it goes live? Take a look at **AI code review**.\n\n## Skills\n\n- [Git Advanced Workflows] (/nl/skills/git-advanced-workflows)\n- [Using Git Worktrees] (/nl/skills/using-git-worktrees)\n- [Finishing a Development Branch] (/nl/skills/finishing-a-development-branch)\n- [Conventional Commit] (/nl/skills/conventional-commit)\n- [Emoji status in commits, PRs and updates] (/nl/skills/gitmoji-status-commits)\n\n## Related services\n\n- [Beoordeling van AI-code] (/nl/services#service-05)\n- [Je eigen programmeeragent] (/nl/services#service-06)\n\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "TechArticle",
                "@id": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten#article",
                "url": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten",
                "headline": "Git: branches, rebase and merge conflicts",
                "description": "Working with feature branches, the difference between ‘merge’ and ‘rebase’, resolving a merge conflict in VS Code, and worktrees for AI assistants.",
                "inLanguage": "en",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten#dataset",
                "name": "Git: branches, rebase and merge conflicts",
                "description": "Working with feature branches, the difference between ‘merge’ and ‘rebase’, resolving a merge conflict in VS Code, and worktrees for AI assistants.",
                "url": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten",
                "identifier": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten#article"
                },
                "publisher": {
                    "@type": "Organization",
                    "name": "DeLaParra Services",
                    "url": "https://delaparra-services.nl/"
                },
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/manuals#dataset",
                    "name": "Manuals for working on your own app",
                    "url": "https://delaparra-services.nl/manuals"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "git-branches-rebase-en-merge-conflicten.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.csv",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "git-branches-rebase-en-merge-conflicten.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.json",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "git-branches-rebase-en-merge-conflicten.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.md",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "git-branches-rebase-en-merge-conflicten.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.pdf",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "git-branches-rebase-en-merge-conflicten.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/manuals/git-branches-rebase-en-merge-conflicten.zip",
                        "inLanguage": "en"
                    }
                ]
            }
        ]
    }
}