Let's do
Let's do this.
We're going to change directory at it here.
I'm going to create a new directory called pi2
cd in the pi2
git init
git remote
add
origin
and I'm going to add the same one.
pull.
Now, I need to
do the whole
origin master again.
And
so now we have two directories that has this project in it.
We're going to Pycharm projects, am going to pi2
I'm going to make changes to this file.
I'm just going to add a comment.
Save that.
Now I'm going to git add -A
and git push
sorry, git push origin master
Alright.
Now, I'm going to change back to my pi directory
and what we're doing right now is we are creating a merge
conflict.
So, if I refresh this page,
I'm going to see the most
recent.
I should.
Now, what happened there?
Ok guys, I've forgot to
commit the changes before pushing.
That's
really silly.
So, let's go back into the pi2 directory.
And I'm going to git commit
"Made some changes
and then git push
to origin master.
Alright, so now if I refresh this page here,
we're going to see the comment in here.
Which is cool.
But,
this came from our pi2 directory.
If we go back to our pi directory, we're going to see
that we don't have that version of those files.
So, this directory now is behind
the actual master branch.
Now, we would normally run git pull
at the beginning of each day,
If you do this professionally,
you run git pull, at the beginning of the day.
and maybe even through out the day.
And make frequent commits.
But let's say you forgot to do that. And now we have a merge conflict.
If I were to pull right now on this directory,
everything would work great because I haven't made changes, so
let's add a different comment here.
And Pycharm
just bricked up on me.
So, I'm going to close that.
Wow!
For Right now, I'm just going to edit this in Git I guess.
Adding
the second
comment to this
file.
I'm going to save,
Now, in the pi directories,
so, go back to the main directory we're working in,
am going to git add -A
git commit, am going to try to push
my changes to the server,
without being aware of the fact that
my local repository is actually behind
the remote repository, so this is what you would do
you'd make your changes, you'd add the file, you'd commit
with
adding new comments and then try to push
And now we see that we get an error message
because we're behind.
And so it's a fetch first. Let's run git fetch
origin master
And
we open up this file
merge conflict.
fix conflicts and then commit to result.
So,
now we've got this.
Because we told it to merge and this is what happens.
The head
is this and this
is a
is a remote server.
So,
we see that it's added some special characters.
That kind of tells us, what is come from what.
So, if you have a huge file, you can always see your changes
versus the changes coming from the server.
And now, you can do some fancy little stuffs like, let's just
keep both comments in here, they're both useful comments.
And then save this file.
Now, we can git
add the file.
git commit
and we're going to say,
merged
conflicts
resolved,
and now we're going to git push
and it's going to succeed, because we've taken care of the conflicts.
So, now if I go back over to this repository, and refresh,
I'm going to see that both of those are in there.
and
that's...
we really need to worry about it, that point.
So, we just learned how to handle merge conflicts,
which is a very useful skill to have.
Pycharm is still bricked up on me entirely.
And I'm not sure why.