- All right, so here I am on the Git website
and let's create this lesson 18 lab.
Creating the repository.
There we go.
Now the easiest way is just to copy/paste all of this
and let's go to Linux so that we can do that.
So I'm mkdir lesson18lab.
Not forget to get into it.
Then I'm pasting all these commands
that were created for me.
Good.
Let me create a couple of files for I in, 1..10.
Do.
Echo $I greater than
$I dot txt, done.
The result is that I have a couple of files that I can use
in my testing and they contain some text as well.
In git tests, I don't like empty files
because empty files by git might be considered
as files with the same content
and that can lead to weird behavior.
I don't want that to happen.
So we are good, and we should be able to continue.
Almost.
First I need git add star to add these nice files.
Git commit minus M, adding nice files,
and then we are good.
And now I can do my git branch testing.
To create a branch, git checkout, testing.
To start using it.
So we switched to the branch testing,
and let me use touch ABC to four dots txt.
Oops, that was a mistake of course.
Echo ABC and echo DEF to five dot txt.
Verifying and you can see that the new files
actually exist.
Now I wanna make sure that this five dot txt
is not going to be synchronized
and in order to do so
I am creating dot git ignore.
And in this dot git ignore
I'm listing five dot txt
Next, git add star.
And you can see the following is ignored.
Five dot txt is ignored.
Well that is exactly what you wanted, right?
So git commit minus M four.
And git push minus, minus set upstream
origin testing.
And that makes sure that the new files are pushed
to the git repository in the new branch.
This git push setup stream is actually very important
because it makes my branch is becoming known
to the people I'm working with on git.
So now I'm using git checkout main
and I'm using LS to verify.
And you can see we do have to file five dot txt.
That's because of the dot git ignore.
It doesn't play ball as far as git is concerned.
But we don't have the file four dot txt
and that's what we are going to fix now
by using git merge testing.
Of course you're free to do a git-diff before you do so.
Now let's use LS.
And now we can see four dot txt again.
Now what is git status saying about it?
It's telling us that we should use git push
because right now the local branch is ahead
of origin main by two commits.
That's not good.
So we want git push to make sure that is synchronized.
And now git status to verify and we can see
that the local branch is up to date with origin main.
And that's it.