You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu环境下本地共享Git仓库的拉取推送与协作权限问询

Hey there! Let's walk through how your colleague can set up your access to that shared internal Git repo, plus the workflow for reviewing and merging your changes—no GitHub required. I’ve handled this exact setup for internal team projects plenty of times, so here’s the breakdown:

Configuring Contributor Permissions (Pull & Push Access)

Since this is an internal shared server, the simplest approach is file system-level permissions, but we can cover a more robust option too.

Option 1: Basic File System Permissions (Quick & Easy for Small Teams)

Your colleague needs to make sure you have read/write access to the repo's directory on the server:

  1. First, create a shared user group for your team (if it doesn't exist already):
    sudo groupadd dev-team
    
  2. Add both your server username and theirs to this group:
    sudo usermod -aG dev-team your-ubuntu-username
    sudo usermod -aG dev-team colleague-username
    
  3. Update the repo directory's ownership and permissions to let the group access it:
    # Replace /path/to/shared/repo.git with the actual repo path
    sudo chown -R :dev-team /path/to/shared/repo.git
    sudo chmod -R g+rw /path/to/shared/repo.git
    # Ensure new files inherit the group permission
    sudo chmod g+s /path/to/shared/repo.git
    

With this setup, you’ll have full pull (and push, if needed) access to the repo.

Option 2: Fine-Grained Permissions (For Larger Teams)

If your team needs stricter controls (like read-only access for some members, or branch-specific restrictions), your colleague can set up Gitolite. It’s a lightweight tool that manages Git permissions via a config file. They’ll need to:

  • Install Gitolite on the server
  • Add your SSH public key to their admin repo
  • Define rules in the gitolite.conf file (e.g., allow you to pull all branches but only push to feature branches)
    This is more work upfront but scales better for bigger teams.
Reviewing Changes & Merging to Master

Without GitHub, you’ll use Git’s native workflows to collaborate. Here are two common, practical approaches:

Workflow 1: Feature Branch Collaboration (Most Common)

This keeps your work isolated until it’s reviewed:

  1. You create a feature branch locally for your work:
    git checkout -b feature/your-feature-description
    # Do your work, commit changes
    git add .
    git commit -m "Add user profile edit functionality"
    
  2. Push your feature branch to the shared server:
    git push origin feature/your-feature-description
    
  3. Notify your colleague to review. They’ll pull your branch locally to check:
    git fetch origin
    git checkout feature/your-feature-description
    # Run tests, review code, check for bugs
    
  4. If approved, your colleague merges it into master:
    git checkout master
    # Use --no-ff to preserve branch history for easier debugging
    git merge --no-ff feature/your-feature-description
    # Push the updated master to the server
    git push origin master
    
  5. Clean up the feature branch (local and remote):
    # Delete local branch
    git branch -d feature/your-feature-description
    # Delete remote branch
    git push origin --delete feature/your-feature-description
    

Pro tip: Always pull the latest master into your feature branch before pushing to avoid merge conflicts:

git checkout feature/your-feature-description
git pull origin master
# Resolve any conflicts, commit, then push

Workflow 2: Patch-Based Review (For Formal/Remote Teams)

If you prefer using email or internal chat to share changes, you can generate patches:

  1. Create a patch file for your recent commits (replace 3 with the number of commits you want to share):
    git format-patch -3 origin/master
    
    This creates .patch files you can send to your colleague.
  2. Your colleague applies the patch to their local repo to review:
    # To just preview changes
    git apply --stat 0001-Add-user-profile-edit.patch
    # To apply the patch to their working directory
    git apply 0001-Add-user-profile-edit.patch
    # Or to merge it directly into a branch
    git am 0001-Add-user-profile-edit.patch
    
  3. Once approved, they merge the changes into master and push to the server.

内容的提问来源于stack exchange,提问作者Majid Azimi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:24:20