Git Command for Collaboration

Author: Cassiel Date:Jan 6th 2017

I have been work on a project with my teammates but I always run into some conflicts problem. So I have spent this whole morning to try to fix it under my friend Sam's help. Thanks to him, I finally solve the problem and I also want to share this article so other people can save their time on Git collaboration.

Firstly, you have to make sure there is a sub-branch on the remote github page such as ting_development. Let's get start our hands dirty.

Find the repository you wanna work on and copy their git link like [email protected]:something. Then in your terminal, direct to the work space where you wanna put your project repository, try git clone [email protected]:something. After this process is done, you will have a same repository with the orignal one on your local machine. Before you get start, you can type git branch -a to take a look at branches. If everything is all right, you can see your remote sub branch such as ting_development.

Okay. Let's start our steps. Every day before you make any changes on your local repository, do steps as following:


git checkout master   # go to your local master branch
git fetch   # try to fetch the latest updates from remote origin master
git status   # check the status of remote origin master
git pull   # pull all the updates from remote origin master and merge into your local master branch. This pull equals to fetch & merge two steps
git checkout ting_development   # switch to ting_development branch
git merge master # merge changes from the remote master to local master

# If all messages you get so far are up to date, then make changes on your local files
git status
git add *
git commit -m ‘commit messages’
git push

# then go to the github pages and go to your branch, find your commit message and start a pull request, merge. Then:
git checkout master
git fetch
git status
git pull
# the steps above are aim to let your master branch sync to the remote origin master
git checkout ting_development
git merge master
git status   # ahead of remote ting_development dev
git push    # this step will try to push all your changes you made on local ting_development branch to remote ting_development branch.

I hope this will help some of you who run into the same trouble with me. =) Happy coding ~

你可能感兴趣的:(Git Command for Collaboration)