
{"id":2864,"date":"2025-07-22T04:20:02","date_gmt":"2025-07-21T20:20:02","guid":{"rendered":"https:\/\/trudsitsolutions.com\/?page_id=2864"},"modified":"2025-07-22T04:20:04","modified_gmt":"2025-07-21T20:20:04","slug":"manage-access-and-best-practices-for-sharing-code","status":"publish","type":"page","link":"https:\/\/trudsitsolutions.com\/index.php\/manage-access-and-best-practices-for-sharing-code\/","title":{"rendered":"Manage Access and Best Practices for Sharing Code"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>Measures to Control Access and Best Practices:<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. <strong>Repository Visibility: Keep it Private!<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Most Important:<\/strong> Ensure your repository is <strong>private<\/strong>. This is fundamental. If it&#8217;s public, anyone can see and clone all your code, including all branches, always.<\/li>\n\n\n\n<li>If your repository is currently public, navigate to its settings on GitHub, go to the &#8220;Danger Zone&#8221; section, and change its visibility to &#8220;Private.&#8221;<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. <strong>Invite as an &#8220;Outside Collaborator&#8221; (Personal Account) or &#8220;Member&#8221; with Limited Role (Organization Account)<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Personal Account (Your personal GitHub profile owns the repo):<\/strong>\n<ul class=\"wp-block-list\">\n<li>Go to your repository on GitHub.<\/li>\n\n\n\n<li>Click &#8220;Settings&#8221; (usually near the top right).<\/li>\n\n\n\n<li>In the sidebar, click &#8220;Collaborators and teams&#8221; (or &#8220;Access&#8221; then &#8220;Collaborators&#8221;).<\/li>\n\n\n\n<li>Click &#8220;Add people.&#8221;<\/li>\n\n\n\n<li>Search for their GitHub username or email.<\/li>\n\n\n\n<li><strong>Choose &#8220;Write&#8221; permission.<\/strong> This allows them to push to branches, create new branches, and open pull requests. It does <strong>not<\/strong> give them administrative control over your repository.<\/li>\n\n\n\n<li>They will receive an email invitation that they must accept.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. <strong>Implement Branch Protection Rules (Crucial for Write Access Control)<\/strong><\/h4>\n\n\n\n<p>This is how you enforce that developers (including freelancers) don&#8217;t directly push to sensitive branches like <code>main<\/code> or <code>develop<\/code>.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>On GitHub:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Go to your repository.<\/li>\n\n\n\n<li>Click &#8220;Settings.&#8221;<\/li>\n\n\n\n<li>In the sidebar, click &#8220;Branches.&#8221;<\/li>\n\n\n\n<li>Under &#8220;Branch protection rules,&#8221; click &#8220;Add rule.&#8221;<\/li>\n\n\n\n<li><strong>Branch name pattern:<\/strong> Enter the name of your protected branch (e.g., <code>main<\/code>, <code>develop<\/code>). You can create multiple rules for different branches.<\/li>\n\n\n\n<li><strong>Recommended settings for protected branches (like <code>main<\/code>):<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Require a pull request before merging:<\/strong> This is the cornerstone of good workflow. It means <em>no one<\/em> (except repository admins, or those explicitly allowed to bypass) can push directly to <code>main<\/code>. All changes must go through a pull request.\n<ul class=\"wp-block-list\">\n<li><strong>Require approvals:<\/strong> Set a number of required reviews (e.g., <code>1<\/code> or <code>2<\/code>). This means another person (you or someone else) must approve the changes before they can be merged.<\/li>\n\n\n\n<li><strong>Dismiss stale pull request approvals when new commits are pushed:<\/strong> Ensures reviews are fresh.<\/li>\n\n\n\n<li><strong>Require review from Code Owners (if you set them up):<\/strong> Good for larger projects.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Require status checks to pass before merging (if you use CI\/CD):<\/strong> E.g., tests must pass.<\/li>\n\n\n\n<li><strong>Include administrators:<\/strong> (Optional but highly recommended) Apply these rules to admins too, to prevent accidental direct pushes.<\/li>\n\n\n\n<li><strong>Do not allow bypassing the above settings:<\/strong> Unless you have a very specific reason for an admin to bypass.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">4. <strong>Workflow for the Freelancer<\/strong><\/h4>\n\n\n\n<p>With the above in place, the freelancer&#8217;s workflow will be:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Clone the repository.<\/li>\n\n\n\n<li><code>git checkout feature\/deduction-fix<\/code> (or whatever branch name you give them).<\/li>\n\n\n\n<li>Make their changes, commit locally.<\/li>\n\n\n\n<li><code>git push origin feature\/deduction-fix<\/code> (push to their working branch).<\/li>\n\n\n\n<li><strong>Create a Pull Request (PR) on GitHub:<\/strong> From <code>feature\/deduction-fix<\/code> <em>into<\/em> <code>develop<\/code> or <code>main<\/code> (whichever is your integration branch).<\/li>\n\n\n\n<li>You (or another designated reviewer) will then review the PR.<\/li>\n\n\n\n<li>Once approved, you will merge the PR. The freelancer generally won&#8217;t have permission to merge into a protected branch themselves.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Best Practices for Sharing Code with a New Freelancer:<\/strong><\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Clear Communication:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Onboarding:<\/strong> Provide a clear onboarding document or conversation covering your expectations, communication channels, code standards, and the Git workflow.<\/li>\n\n\n\n<li><strong>Scope of Work:<\/strong> Clearly define the task, deliverables, and timelines. Use GitHub Issues for task tracking.<\/li>\n\n\n\n<li><strong>Code Review Expectations:<\/strong> Explain your code review process.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Start with a Small, Isolated Task:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The payroll deduction fix is a good example because it&#8217;s a specific, contained problem. Avoid giving them access to the entire codebase for a broad, undefined task initially.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Use Private Repositories:<\/strong> As discussed, essential for proprietary code.<\/li>\n\n\n\n<li><strong>Least Privilege Principle:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Grant the minimum necessary permissions. &#8220;Write&#8221; access is usually sufficient for a developer. Avoid giving &#8220;Admin&#8221; access unless absolutely necessary.<\/li>\n\n\n\n<li>For organizations, use custom roles or teams to fine-tune permissions.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Branching Strategy:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Use a clear branching strategy (e.g., GitFlow, GitHub Flow). For a freelancer, a feature branch (<code>feature\/deduction-fix<\/code>) off your <code>develop<\/code> branch (or <code>main<\/code> if it&#8217;s your primary development branch) is ideal.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Code Reviews (Pull Requests):<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Always<\/strong> require code reviews for any freelancer&#8217;s work before merging into core branches (<code>main<\/code>, <code>develop<\/code>). This is your primary quality control and security gate.<\/li>\n\n\n\n<li>Provide constructive feedback.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><code>README.md<\/code> and Documentation:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Ensure your repository has a comprehensive <code>README.md<\/code> with setup instructions, how to run tests, and any critical information about the project structure.<\/li>\n\n\n\n<li>Good comments in the code itself are also invaluable.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Environment Variables &amp; Sensitive Data:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Never<\/strong> commit sensitive data (API keys, database credentials, secret keys) directly into the repository.<\/li>\n\n\n\n<li>Use environment variables (e.g., a <code>.env<\/code> file that&#8217;s <code>.gitignore<\/code>d) for local development and a secure vault (like AWS Secrets Manager, Azure Key Vault, HashiCorp Vault) for production.<\/li>\n\n\n\n<li>Instruct the freelancer on how to set up their local environment variables.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Two-Factor Authentication (2FA):<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Strongly encourage or require<\/strong> all collaborators, especially external ones, to enable 2FA on their GitHub accounts for added security. If you&#8217;re on a GitHub Organization, you can enforce this.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Offboarding Process:<\/strong>\n<ul class=\"wp-block-list\">\n<li>When the freelancer&#8217;s contract ends, <strong>immediately remove their access<\/strong> from your GitHub repository (and any other systems they had access to).<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Measures to Control Access and Best Practices: 1. Repository Visibility: Keep it Private! 2. Invite as an &#8220;Outside Collaborator&#8221; (Personal Account) or &#8220;Member&#8221; with Limited Role (Organization Account) 3. Implement Branch Protection Rules (Crucial for Write Access Control) This is how you enforce that developers (including freelancers) don&#8217;t directly push to sensitive branches like main [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2864","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/trudsitsolutions.com\/index.php\/wp-json\/wp\/v2\/pages\/2864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trudsitsolutions.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/trudsitsolutions.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/trudsitsolutions.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trudsitsolutions.com\/index.php\/wp-json\/wp\/v2\/comments?post=2864"}],"version-history":[{"count":1,"href":"https:\/\/trudsitsolutions.com\/index.php\/wp-json\/wp\/v2\/pages\/2864\/revisions"}],"predecessor-version":[{"id":2865,"href":"https:\/\/trudsitsolutions.com\/index.php\/wp-json\/wp\/v2\/pages\/2864\/revisions\/2865"}],"wp:attachment":[{"href":"https:\/\/trudsitsolutions.com\/index.php\/wp-json\/wp\/v2\/media?parent=2864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}