The workflow for Git collaborations typically follows this order:
- Fetch and merge changes from the remote
- Create a branch to work on a new project feature
- Develop the feature on your branch and commit your work
- Fetch and merge from the remote again (in case new commits were made while you were working)
- 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.
- A 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.
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: Mergesorigin/masterinto your local branch.
git push origin <branch_name>: Pushes a local branch to theoriginremote.
2202

被折叠的 条评论
为什么被折叠?



