Skip to content

MaximeCulea/meetup-git

Repository files navigation

Introduction au gestionnaire de version GIT

WP Meetup Geneva

WP Meetup Paris

General git workflow

  1. add a file from IDE : maxime.php
  2. add it to git : git add maxime.php or all files with git add .
  3. edit the file then commit changes : git commit -m "my first commit"
  4. push them : git push origin master

Git Conflict

  1. create a new branch from master : git checkout -b evol/1
  2. edit the file :
<!DOCTYPE html>
<html>
<body class="toto">

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>
  1. push the changes : git push origin evol/1
  2. create from master a other one : git checkout -b evol/2
  3. edit the file :
<!DOCTYPE html>
<html>
<body class="toto titi">

<h1><?php the_title(); ?></h1>
<p>My first paragraph.</p>

</body>
</html>
  1. push changes : git push origin evol/2
  2. we can change branches (content) as we want : git checkout evol/1
  3. on server, only get the modifications : git fetch -a
  4. to apply the new modifications : git pull -f
  5. finally merge the two branches on master :
    • go on master : git checkout master
    • merge branches : git merge evol/1 and git merge evol/2
  6. it results into a conflict :
    • edit the final modification into the file
    • stage changes : git add .
    • then commit them : git commit -m "Resolved merge conflict by incorporating both suggestions."