• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Git & Github: Quick Setup Guide

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
What is Git


Git is a version control system that allows multiple developers in a team collaborate on a project in real time, by tracking changes to source codes.

Key Git Concepts

  • Repository - A folder where Git stores your project's code and its history of changes. It can be stored Locally or Remotely.
  • Clones - A copy of a remote repository on your computer.
  • Pull - Getting the lates changes from a remote repository.
  • Push - Saving your changes to a remote repository.
  • Commit - A snapshot of changes made to the repository.
  • Branch - A parallel version of the repository.
  • Merge - Combining changes from different branches.
What is Github


GitHub is a cloud-based platform based on Git, which hosts code repositories and helps developers collaborate.

Setting up Git


Git can be downloaded from

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



  • For windows: Simply download and run the installer to install Git and Gitbash
  • For MacOS: Open terminal and run $ brew install wget to install brew, then run $ brew install git.
Configuring Git


Git requires your Username and email address to label your commits.
To add Username, run


$ git config --global user.name "Username"

To add Email Address


$ git config --global user.email "email@example.com"
Creating a Repository


using terminal on MacOS, or Git bash on Windows, create a directory for your project.


$ mkdir git-lab

Change the working directory to the one we just created.


$ cd git-lab
Initialize Git


To create our Repository in this directory, run


$ git init

A simple Html file can be created via the notepad or using the terminal.


$ touch index.html

To quickly add text to the html file


$ echo "this is an index file for my first repo" > index.html

Then we check the status of our file


$ git status

At this point, it is untracked. This means it is present in our folder, but it's absent from the staging area.

So we need to tell Git to track our file.


$ git add index.html

or git add -all , git add -A or git add . to add all the files in the directory.

To unstage a file


git restore --staged index.html

Then check the status.

Commit


To save the staged file(s)


$ git commit -m "My first commit"

To see previous commit history,


$ git log
Branches


If we wanted to add changes to our project without affecting the main project, we create a branch.


$ git branch "parallel-repo"

To see all branches


$ git branch

To switch between branches


$ git checkout parallel-repo

To delete a branch


$ git branch -d parallel-repo
Merging


To combine changes from one branch into another, first switch to the branch you want to merge into(main or master)


$ git checkout main

Now we merge


$ git merge parallel-repo
Creating a Remote Repo


Go to

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

and create a new repository.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


Copy git remote add origin

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

, then paste in terminal and run.

Finally run,


$ git push -u origin main

Git would ask to authorize Github, then the local commit gets pushed to the Github repository.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу