Git allows developers to work together by distributing changes and code across remote repositories. There are two main ways to integrate changes from other branches: merging, which combines changes chronologically, and rebasing, which rewrites the commit history to put local changes on top. Conflicts can occur when applying changes if the same code blocks were modified differently in separate branches. Developers must resolve conflicts before completing the merge or rebase.
1. Culture Of
Working Together With GIT
Next Step After Add, Commit, Push
Ibrahim Gunduz
ibrahimgunduz34@gmail.com
https://twitter.com/ibrahimgunduz34
https://github.com/ibrahimgunduz34
2. Agenda
● GIT fundamentals
● What is the difference between merge and rebase ?
● When have we need to use merge or rebase ?
● What does it mean conflicts and how does it happen ?
● Let’s begin to try!
3. ● GIT works as distributed and
doesn’t know any updates until you
fetch changes from remote. So you
must call git fetch command first
to getting changes.
GIT Fundamentals
4. GIT Fundamentals
● GIT doesn’t apply any changes to your
code unless you merged changes with
your branch. So you should apply
merge methodology which is available
for you. (merge or rebase)
6. What Is The Difference Between Merge And Rebase ?
Merge
● merge command, merges the
specified branch via argumant
with current branch as
chronologically. (merge
depending on the time)
7. What Is The Difference Between Merge And Rebase ?
Rebase
● rebase command, apply changes
after your merge base that came
from base branch and put your
changes to top of branch which
is commit by yours after merge
base of the current branch.
8. When Have We Need To Merge Or Rebase ?
● GIT compare your branches with remote by the commit sequence when you
pushed to remote
● You mustnt’t run git pull command when you encountered the following
message if you aren’t sure:
9. When Have We Need To Merge Or Rebase ?
● If you are working with your colleague in same branch:
$ git pull --rebase origin YOUR_BRANCH_NAME
● If you want to recieve updates to your feature branch from master
$ YOUR_BRANCH > git fetch upstream
$ YOUR_BRANCH >git rebase upstream/master
● If you want to update your master branch (or stage, dev..)
$ master > git pull upstream master
10. What does it mean conflicts and how does it
happen ?
● Conflicts happen when any code bocks has two different revision while
applying changes.
● <<<HEAD means head of the your local branch.
● Commit hash that came after equeal block is to be applied commit.
Working on same branch
A creates a new branch from master and push to origin (Each team create a branch for themself)
B fetch updates from remote and checkout the branch
A makes commit
B makes commit
A push changes
A make new commit
A push changes
B push changes (B faced with pull error)
Team A push the branch to remote and they merge the branch to master and push it
Fetching updates from master to feature branch
A fetch updates from upstream
A make rebase own feature branch by the upstream master
A push the branch with force parameter
Updating master branch
Each team can run git pull origin master in their