Tip:
Highlight text to annotate it
X
Hello Ace
This is RetroTK2 and welcome to this Version Control tutorial
Today, we're collaborating with another dev using Git Ace
Make sure you checkout my other version control videos Ace, as a lot of the concepts we'll discuss here have been explained in greater detail in them
So let's get started...
Say we have another dev called Joe who wants to work on our project Ace
Joe can clone the repository using the Remote's path
Once cloned, Joe's repository will contain an exact copy of the files on the remote repo
Let's see what happens when we both make changes to the project Ace
Here I'm adding two different files to each of the repositories
Stage the Changes, Commit the Changes and push the changes Ace
Nothing new on Joe's side so far
Same on my side Ace, stage and commit, but when we try to push the changes, I get an error
Since Joe has pushed his changes to the remote repository, we need to “fetch” his changes, in order to add them to our repository
We then need to “merge” the changes with our “master” branch and “push” those changes to the remote repository
This may seem a bit tough to get your head around at first Ace, but we'll take it slow
First, we need to get the changes from the remote repository and put them into our repo
Click the “Fetch” button in the top menu and click “OK”
Now we can see that our “master” branch is one commit ahead with my commit and one commit behind with Joe's commit
Now we need to merge Joe's changes into our branch
Click on the “Pull” button in the top menu Ace
You should probably uncheck the box beside “Commit merged changes immediately”, as it gives you a chance to check the files manually before you commit them Ace
I didn't do this for the first pull
Click “OK”
Since I didn't uncheck the box, SourceTree has automatically created a “merged” commit for me Ace
Now both my changes and Joe's have been commited to my “master” branch
We're ready to push these changes to the remote Ace
Click the “push” button and our remote will receive the changes
In the “Graph” column, we can see a new fork in the “master” branch where Joe committed his changes
If I pull up both repositories, you'll see I have Joe's file in my project's root folder
Since Joe hasn't pulled my changes yet the “My Change” file isn't present in his project
This was an easy merge between two projects Ace, since there was no conflicting files
Let's have a look at a merge with a conflicting file
Say I make a change to the “Added File” and Joe also makes a similar change to the “Added File”
Here I stage, commit and push first Ace
Now Joe stages, commits, and clicks the “Pull” button
Since we're working with another dev, it's often safe to assume that a change has been added to the remote repo Ace
The sequence “stage”, “commit” and “push” can be altered slightly to “stage”, “commit”, “pull”, “merge” if required and then “push”
With the “pull” request, git will execute the “fetch” command as well, so there's no need to press the “fetch” button if your planning to “pull” Ace
Here I uncheck the “Commit merged changes immediately” and click “OK”
Now we get an error when we pull Ace
If we check our “Uncommitted changes”, we see there's a “warning” icon beside “Added File”, signifying a conflict with that file
There are a few was to deal with this Ace
Right click on the file and move to “Resolve Conflicts”
Here we can choose to “Resolve Using 'Mine'” or “Resolve Using 'Theirs'”
Since this is Joe's repository, 'Mine' refers to Joe's changes and 'Theirs' refers to my changes
Be care with this Ace, since 'Mine' won't always mean you
This becomes tricky when you're trying to merge two different branches Ace, since 'Mine' and 'Theirs' could refer to two different branches that you've worked on
But we'll talk about that in a future video
Another option is to go into the file and manually change it
Since we're merging, both files have been merge into one Ace
The line of text that says “