Git Basic Collaboration Workflow

The workflow for Git collaborations typically follows this order:

  1. Fetch and merge changes from the remote
  2. Create a branch to work on a new project feature
  3. Develop the feature on your branch and commit your work
  4. Fetch and merge from the remote again (in case new commits were made while you were working)
  5. Push your branch up to the remote for review

Steps 1 and 4 are a safeguard against merge conflicts, which occur when two branches contain file changes that cannot be merged with the git merge command.


Specifically,

First, make a local copy of the project. You can use:

    git clone remote_location clone_name

1. Fetch and merge changes from the remote

    git fetch origin master

This command will not merge changes from the remote into your local repository. It brings those changes onto what's called a remote branch (e.g. origin/master).

Then we'll use the git merge command to integrate origin/master into your local master branch. 

    git merge origin/master


2. Create a branch to work on a new project feature

    git branch <branch_name>

    git checkout <branch_name>


3. Develop the feature on your branch and commit your work

    git add somefile

    git commit -m "message"


4. Fetch and merge from the remote again (in case new commits were made while you were working).

5. Push your branch up to the remote for review

    git push origin <branch_name>


GIT TEAMWORK
generalizations

Congratulations, you now know enough to start collaborating on Git projects! Let's review.
  • remote is a Git repository that lives outside your Git project folder. Remotes can live on the web, on a shared network or even in a separate folder on your local computer.
  • The Git Collaborative Workflow are steps that enable smooth project development when multiple collaborators are working on the same Git project.
We also learned the following commands
  • git clone: Creates a local copy of a remote.
  • git remote -v: Lists a Git project's remotes.
  • git fetch: Fetches work from the remote into the local copy.
  • git merge origin/master: Merges origin/master into your local branch.
  • git push origin <branch_name>: Pushes a local branch to the originremote.
Git projects are usually managed on Github, a website that hosts Git projects for millions of users. With Github you can access your projects from anywhere in the world by using the basic workflow you learned here.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值