Git Commands and Workflows - PDF

Summary

This document appears discusses Git, a popular version control system. It provides information on commands, and workflows such as Gitflow. It covers topics like branching, merging, and storing file modifications.

Full Transcript

**Github** - kodų talpinimo platforma, skirta valdyti versijas ir bendradarbiauti. Galimybė dirbti komandoje prie vieno ar kelių projektų, kuriuos galima pasiekti iš bet kur. **Versijų kontrolė** - angl. version control, reivison control. Versijuojamų failų istorijos ir pokyčių valdymas. Pokyčių pe...

**Github** - kodų talpinimo platforma, skirta valdyti versijas ir bendradarbiauti. Galimybė dirbti komandoje prie vieno ar kelių projektų, kuriuos galima pasiekti iš bet kur. **Versijų kontrolė** - angl. version control, reivison control. Versijuojamų failų istorijos ir pokyčių valdymas. Pokyčių peržiūra, pokyčių palyginimas, pokyčių dalijimasis, atsikų izoliuotų pokyčių aplinkų kūrimas (angl. branching) **Centralizuotos** - turi vieną pagrindinę nuotolinę repo. Pagrindinė repo turi pilną versijų istoriją. **Decentralizuotos** - gali turėti daug nuotolinių repo. Kiekviena repo su pilna istorija. **Git privalumai:** Kiekviena repo - "smėlio dėžutė", galima dirbti be interneto, greita/naši, paprasta dirbti su pakeitimais, efektyvus šakojimo ir suliejimo mechanizmas. **Git būsenos** - pakeitimai darbinėje direktorijoje pirmiausia patenka į indeksą, naudojant git add komandą. Į repo pakeitimai patenka tik iš indekso, naudojant komandą git commit, kuri tuos pakeitimus išsaugo ir tokiu būdu gimsta versijos įrašas - revizija. **konfigūravimas** - komandos narių pakvietimas, main šakos apsaugojimas (add classic branch protection rule pvz. pakeitimus į main galima įkelti tik per PR, reikalingi PR approvals) **.gitignore** - tekstinis failas leidžia nurodyti šablonus kelių, kurie neturi būti tvarkomi Git'o. (tai failai kurie neturi būti commitinami, pvz. logai, kompiliuoti failai, priklausomybių katalogai) **github fork** **/ forking workflow** - The forking workflow is common in open-source projects where contributors fork the central repo into their accounts, make changes in their forks, and submit pull requests to propose changes to the original repo. **Feature branching** - feature branching creates a separate branch for each new feature or task. Developers work on these isolated branches, and once feature is complete and reviewed it is merged back into the main branch. This allows parallel development without affecting the stable codebase. **Staging Server**: A safe space for final testing before going live. **Production Server**: The live environment where the application is used by end users. Having both environments helps ensure a smooth and reliable deployment process, reducing the risk of issues affecting the live application. **Gitflow workflow** - gitflow is a structured branching model with two main branches (main and develop) and supporting branches for features, releases and hotfixes. Developers create feature branches from develop, merge them back after completion, and create release branches for finalizing versions and hotfix branches. Git komandos: **git init** - lokalios repo inicializavimas. Paruošia dabartinį katalogą kaip git repo.(Initialize a new git repo in the current directory) Note: pirmą kartą paleidus git, reikia pridėti git config (arba --global )l user name ir user email **git log** - leidžia peržiūrėti visų pakeitimų istoriją dabartinėje šakoje. Atvaizduoja SHA-1 identifikatorių, autoriaus vardą, datą (kuomet atliktas komitas), komito pranešimą) **git status** - dabartinė repo būsena (git status gives information on the current status of git repo and it's contents) **git stash -** temporarily store all modified tracked files and changes to allow switching branches **git add.** - pokyčių pridėjimas į indeksą. Prideda [viską] iš dabartinio katalogo. (add all new, modified and deleted files in the current directory and it's subdirectories to the staging area) **git add -A** - add all new, modified, and deleted files in the entire repo to staging area **git branch -** List Branches, Create a New Branch, Delete a Branch, Rename a Branch, List Remote Branches, List All Local and Remote Branches, Show the Last Commit on Each Branch **git checkout** - navigacija per istoriją **git checkout** - Switching Branches, Creating and Switching to a New Branch, Restoring Files, Checking Out a Specific Commit **git checkout commit \** - to view previous commit **git checkout -b** - The git checkout -b \ command is used to create a new branch and switch to it immediately. It\'s a convenient way to both create and switch branches in one step. Just so you know, Git introduced the git switch command which is more intuitive for branch switching. **git commit -m** - pokyčių išsugojimas į repo. Commit the staged changes/files with a given message. Commits with a one-line message. This command creates a commit with a message. It includes changes from the files that have been **manually staged** using git add. **git commit -am** - add all tracked, modified files to the staging are and commit them with given message). git commit -am \"message\": This command creates a commit with a message as well. However, it also **automatically stages** changes for all tracked files before making the commit. This means you don\'t need to use git add for those files. (not recommended) **git commit --amend** - Modify the most recent commit by including additional changes or updating the commit message. Amend only works with the very last commit. Amend rewrites the commit history in your repo. Don't amend commits that you've already published to a remote repo. **git merge -** The git merge command is used to combine changes from one branch into another. Merge the specified branch into the current branch. **git clone \[URL\]** - Clone an existing repository by it's URL into a new directory. Jeigu mes atsisiuntėme repozitoriją su git clone \, automatiškai priskiriamas remote origin. **git remote -v** - Display the URLs of remote repos along with their names **git pull origin master** - [Fetch and merge] changes from the origin's master branch into your current branch **git fetch origin** - retrieve updates and information from remote repo [without merging them ] **git push origin master** - Push local branch commits to the remote repo branch (pakeitimų išsiuntimas į nutolusią repo) **git remote add origin \** - Add remote repo with a specific name and UR (jeigu repo sukurta su **git init** remote origin pridėti reikia patiems) **git reset --soft** - undo last commit, but keep the changes in the working directory. This mode moves the HEAD pointer to the specified commit, but it leaves the working directory and the staging area (index) unchanged. **git reset --mixed** - (default): This mode moves the HEAD pointer to the specified commit and **resets the staging area (index)** to match that commit. However, it leaves the working directory unchanged. **git reset --hard** -This mode moves the HEAD pointer to the specified commit and **resets both the staging area (index) and the working directory** to match that commit. All changes are discarded. soft: Changes remain staged. mixed: Changes are un-staged. hard: Changes are discarded. **Detached head** - when HEAD pointing to specific commit instead of a branch.

Use Quizgecko on...
Browser
Browser