Difference between #2 and #3 of
Collaborative software with git

Revision #3 has been created by Maurizio Domba Cerin on Feb 24, 2012, 8:05:30 AM with the memo:

styled commands and grammar fixes
« previous (#2)

Changes

Title unchanged

Collaborative software with git

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

git, github, collaborative software, pull

Content changed

Git basics ... -------------- The most difficult thing in big project, is to manage conflicts with files modified by others users. Git can do this work for us.
 
I can create a project on my local computer     $ git init I can add files to it     $ git add .     $ git commit -m 'A little story to understand changement' I can create a repository on github (or bitbucket). I can add this remote repository to my own local project:     $ git remote add origin git@github.com/<yourusername>/<yourrepository>.git And then I can push my committed files to the remote repository.     $ git push origin master Collaborative software ---------------------- But what if we work with others developer? What if we make changes into the same files? I'll give an answer to this question. ### Better case: no conflicts In better cases, there are no conflicts. This means that a developer can change the view. Another one the model. Both coan run the sequence:     $ git add .     $ git commit -m 'committed some stuff'     $ git push origin master

### Worst case: conflicts
[...]
Imagine to have your new project:

    $ git init     $ touch readme     $ git add .     $ git commit -m 'first commit' Now, if you want, you can see the graph of your project:     $ git log --graph --oneline The output will be like this:     * 719b3f2 first commit This is your version 0.0. You can create a branch 0.0.     $ git checkout -b 0.0 So you'll have a branch in all life of this project. But what if you want to add some features for version 0.1? You can call this new feature like 'add an index file' and 'add a changelog file'. Point to 0.0 version and create a branch. Add some files. Commit. ... follow these steps:     $ git checkout 0.0     $ git checkout -b 0.1.index     $ touch index.php     $ git add .     $ git commit -m 'Added index file' Take a look again to the graph of your poroject:     * 21cb1bc Added index file     * 719b3f2 first commit Come on!!! =) We can add new feature before release 0.1 version!     $ git checkout 0.0     $ git checkout -b 0.1.changelog     $ touch changelog.md     $ git add .     $ git commit -m 'Added changelog' Again to the graph     * e9fe3ad Added changelog     * 719b3f2 first commit We have two steps because with "$ git checkout master" we have started this branch from 0.0. Now we have 0.0, 0.1.changelog and 0.1.index branch. What you need, now, is create your version 0.1:     $ git checkout master     $ git checkout -b 0.1     $ git merge 0.1.index     $ git merge 0.1.changelog And now?     $ git log --graph --oneline     * 3dbd397 Merge branch '0.1.changelog'     |\     | * e9fe3ad Added changelog     * | 21cb1bc Added index file     |/     * 719b3f2 first commit

Now we can see our two branch.
[...]
#### Manage conflicts with other developers

I
t's very dangerous to manage conflicts ion merge with others developers. I suggest to use a good practice. The first timeFirst you can clone your project. Then you can commit ion your local master. But ... what you can do to update your version to the remote versione?     $ git pull origin master Pull execute 2 command. The first is "git fetch" that update your code. And the second one is "git merge". So, your code is merged with the one the is online. Now you can push your code to remote repository stored on github.     $ git push origin master
9 0
9 followers
Viewed: 13 855 times
Version: 1.1
Category: Tutorials
Written by: sensorario
Last updated by: Maurizio Domba Cerin
Created on: Feb 21, 2012
Last updated: 12 years ago
Update Article

Revisions

View all history