RUVIDEO
Поделитесь видео 🙏

GitHub tutorial 09: Work on custom branch

One of Git advantages is the ease of switching back and forth between a custom branch and master branch. It is the basis for collaboration within a team environment, and makes Git suitable for projects that have a scheduled release cycle. A custom branch can be a develop branch, feature branch, or release branch.

Git branching is incredibly lightweight, operates nearly instantaneous. It's essential to understand and master this feature for your development practice.

Internally, a Git branch is a movable pointer to one of the commits. It is actually a simple file that contains the 40 character SHA-1 checksum of the commit it points to. You can see why branches are cheap to create and destroy. Creating a new branch is basically to create a new pointer for you to move around in the repository, and is as quick and simple as writing 41 bytes to a file (40 characters and a newline).

There are two Git commands to create and switch to a branch, for example, a branch named "develop":
$ git branch develop
$ git checkout develop

There is a shortcut to combine these two commands into one with -b switch, like this:
$ git checkout -b develop

I prefer using two commands method. You can choose either shortcut command or separated commands.

The commands to add changes to local and remote repository are the same between working on custom branch and master branch. At some point, you may decide to merge the changes from custom branch back to master branch. Here are three commands you can use to accomplish this merging process.

First, you can use "checkout" to switch to master branch.

Then merge the change from custom branch, for example, let's still call it develop branch.

If there are conflicts, Git will add standard conflict-resolution markers. Resolve those conflicts manually. To keep this tutorial session focus on the main topic, I will skip the details of how to resolve the merge conflicts, and leave it as a separate topic in the future tutorial. After the merge conflicts have been resolved, use Git "add" and "commit" commands to finalize the merge into local repository.

Finally, push the merge to remote repository. If the develop branch is no longer needed, you can delete it with "-d" option:
$ git branch -d develop

Now it's the time for a live demo.

Change directory to local git repository in PowerShell. Mine is at c:\temp\demo. Since posh-git module is used, it is clear that we are in master branch.

To list all the branches, use:
$ git branch -a
There is only one branch in my repository. It is master, in color green.

Now create a new branch with name "develop":
$ git branch develop
List all the branches again. Now "develop" in color white is on top of "master".

Switch to this branch with:
$ git checkout develop
Notice the new branch name shows up in the status information area.

Next, set the current branch to track the remote branch with:
$ git branch --set-upstream-to=origin/develop
This makes pull and push easier since you don't need to mention the branch name anymore, which will be obvious in the following steps.

Synchronize with remote branch with:
$ git pull
It shows "Already up to date".

Push to remote branch with:
$git push
It shows "Everything up-to-date"

Let's add a new file with Notepad: demo-02.txt. Click "Yes" to create this new file.

Add it to staging area, and commit to local repository with comment: added a new file in develop branch.

Modify the new file with text: hello branch develop.

Add the change to staging area, and commit to local repository with comment: modified the new file.

Push the last two commits to remote repository with:
$ git push
Now you see, we don't need to explicitly type the location "origin", and branch name "develop"

You can visually inspect the status of master and develop branch on GitHub web page. Click "Insights" tab, and then go to "Network" diagram. You can see develop branch is ahead of master branch.

Suppose we have finished working on the develop branch, and are ready to merge all the changes into master branch. How to do it?

Switch to master branch with:
$ git checkout master

Merge the change from develop branch with:
$ git merge develop
It shows "Fast-forward", which means there is no divergent work to merge these two branches together.

Finally, push all the changes to remote repository with:
$ git push

Now let's check the "Insights" / "Network" diagram again. Master and develop branch both point to the same place.

If you don't need "develop" branch anymore, you can delete it with:
$ git branch -d develop
Check the result with:
$ git branch -a
Only master branch shows up.

That's the basic procedure to work with a new branch, and merge changes back to master branch.

Thanks for watching!

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «GitHub tutorial 09: Work on custom branch», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.