An open API service indexing awesome lists of open source software.

https://github.com/mikma03/git_github

Repository shows how to use Git.Introduction to Git flow. Useful command and workflow.
https://github.com/mikma03/git_github

bash-script git git-gui github introduction learning-by-doing version-control

Last synced: about 2 months ago
JSON representation

Repository shows how to use Git.Introduction to Git flow. Useful command and workflow.

Awesome Lists containing this project

README

        

# Version control - Git - test

# Table of content

- [Version control - Git - test](#version-control----git---test)
- [Table of content](#table-of-content)
- [Courses provided by GitHub](#courses-provided-by-github)
- [Git with VSC](#git-with-vsc)
- [Useful links](#useful-links)
- [Introduction](#introduction)
- [Materials](#materials)
- [Book](#book)
- [YouTube course](#youtube-course)
- [Git interface (Git Bash/Git GUI)](#git-interface-git-bashgit-gui)
- [git status](#git-status)
- [git config](#git-config)
- [clear command](#clear-command)
- [.gitignore](#gitignore)
- [Branches](#branches)
- [Git Stash](#git-stash)
- [Merge conflict](#merge-conflict)
- [Git Revert and Git reset](#git-revert-and-git-reset)
- [How to change names of commits](#how-to-change-names-of-commits)
- [Fork and Pull Request](#fork-and-pull-request)
- [Git history](#git-history)
- [Pull request](#pull-request)
- [Git rebase & git merge](#git-rebase--git-merge)
- [Git squash](#git-squash)
- [Git cherry-pick](#git-cherry-pick)
- [Tagging](#tagging)

# Courses provided by GitHub

- https://skills.github.com/

## GitHub docs

- https://docs.github.com/en

# Git with VSC

- Intro to VSC and GIT
- https://www.youtube.com/watch?v=Fk12ELJ9Bww&t=8s&ab_channel=AutomationStepbyStep

- Branches in VSC
- https://www.youtube.com/watch?v=F2DBSH2VoHQ&ab_channel=Ihatetomatoes

- TOP 6 Git extensions
- https://www.youtube.com/watch?v=Guva-oab1pg&ab_channel=BryanJenks

- Branches, merge, clone, fork
- https://www.youtube.com/watch?v=3Tn58KQvWtU&list=PLpPVLI0A0OkLBWbcctmGxxF6VHWSQw1hi&ab_channel=DevWorld

# Useful links

- Add Image to GitHub Readme.md from Google Drive
- https://stackoverflow.com/questions/52063556/add-image-to-github-readme-md-from-google-drive/70200170#70200170

Example how to connect to image from Google Drive:

```



```

- When local branch and remote branch are differen and you want work on one branch - one of my issue with Git

- https://stackoverflow.com/questions/69863948/git-creates-a-new-branch-despite-commit-how-to-fix-this

- Gitignore files templates
- https://github.com/github/gitignore

 

# Introduction

This repository consist of usefull materials and shows workflow in version control using Git. Some materials also show how to use GitHub.

 

# Materials

## Book
- Book which cover most informations about GIT
- https://git-scm.com/book/en/v2

## YouTube course
- Git course (for native Polish speaker or those who like subtitles)
- https://www.youtube.com/watch?v=tvHVafvw16Y&list=PLj-pbEqbjo6AKsJ8oE2pvIqsb15mxdrxs&ab_channel=Zaprogramuj%C5%BBycie

 

# Git interface (Git Bash/Git GUI)

## git status
When we want to check status of files in our repositary we can use:

git status

## git config
Settings for new user - add user e-mail:

git config --global user.name "YOUR Name"

E-mal:

git config --global user.email "YOUR EMAIL"`

## clear command
To clear our console just use:

clear

Basic Git flow could look like that:

git add FILE_NAME

git commit -m "your commnet for changes you've done"

git push

The `git add` command adds new or changed files in your working directory to the Git staging area. `Git add` is an important command - without it, no `git commit` would ever do anything. Sometimes, `git add` can have a reputation for being an unnecessary step in development. But in reality, `git add` is an important and powerful tool. `git add` allows you to shape history without changing how you work.

git add *

History of commits. Shows the commit logs.

git log

- More info about `git logs`
- https://git-scm.com/docs/git-log

## .gitignore

We tell git which files will be untracked. Also on GitHub there is a project which cosnsist of templates for gitignore in case of every language.

- Commends for .gitignoge
- https://www.atlassian.com/git/tutorials/saving-changes/gitignore)

- A collection of .gitignore templates
- https://github.com/github/gitignore)

Flow how to add .gitignore file manually

10.1. Create the text file `gitignore.txt`.

10.2. Open it in a text editor and add your rules, then save and close.

10.3. Hold SHIFT, right click the folder you're in, then select Open `command` window here.

10.4. Then rename the file in the command line, with ren `gitignore.txt` `.gitignore`.

# Branches



How can we check where we are in case of branch:

git branch

Create new branch:

git branch NAME_OF_NEW_BRANCH

When we want change branch

git checkout NAME_OF_BRANCH

When we want to make changes on our remotely repository and add new branch which is already exist on our local workspace:

git push -u origin NAME_OF_NEW_BRANCH

Create new brach and autamatillcy checkout branch:

git checkout -b NAME_OF_NEW_BRANCH

Graph of our changes in the console:

git log -oneline -graph -all

# Git Stash



Add something to storage we can use command:

git stash

Check what is in our storage we should use:

git stash list

3. Changes in our storage are indexed and we can acess to then by

 

> `stash@{X}`

 

4. We can add multipletimes changes and updates and everytime our list will be reindexed moreover the latest index is our last change and this is index{0}.
If we want identify difference between stash commit we can use:

 

> `git stash show stash@{X}`

where ```{X}``` is number of stash commit

 

5. When our changes in storage are simillar or commend `git stash show` doesn't show the changes we are interested in then we can use:

 

> `git stash show stash@{X} -p`

 

6. In case when we change two or more files we can use

 

> `git stash save "Descriotion for our changes"`

 

7. When we want apply changes from storage to our file we can use below command, but in this case only the latest commit will be applied. Also in this case
changes are still in storage.

 

> `git stash apply`

 

8. When we want delete changes from storage after adding those to file we can use:

 

> `git stash pop`

 

9. In case when we want apply changes from choosen commit we can use:

 

> `git stash pop stash@{X}`

 

10. When we want delete stash commits form storage we can use

 

> `git stash drop stash@{X}`

 

or when we want everything what is inside of storage

 

> `git stash clear`

 

11. When we want to add new file but that file is untracked by git but we need to add changes in this file to storage then

 

> `git stash -u`

 

or

 

> `git stash -a`

 

12. If we want create new branch for stash commit we should use

 

> `git stash branch NAME_OF_NEW_BRANCH stash{0}`

 

13. Changes made by git stash can be moved to another branch

 

> `git stash pop`

 

# Merge conflict

 

If cinflict appear in out git flow we need to select which part of code we want in our file.
When conflict appera and after taht we select code we need to one again to throught git flow:

 

1. `git add`

 

2. `git commit`

 

3. `git push`

 

# Git Revert and Git reset

 

1. When we want to go back to a selected point in the past on our time line we can do this with:

 

> `git checkout COMMIT_ID`

 

2. In case when we want restore changes form selected commit

 

> `git revert COMMIT_ID`

 

3. History of commits

 

> `git log --oneline`

 

4. To reset old commits we can use

 

> `git reset COMMIT_ID`

 

5. There are two possible reset posibillity

 

> `git reset COMMIT_ID --soft`

 

or

 

> `git reset COMMIT_ID --hard`

 

# How to change names of commits

 

1. When we want change commit we can use

 

> `git commit --amend -m "message update"`

 

2. To display information about one commit we should use

 

> `git show COMMIT_ID`

 

3. In case when we want change more than one commit we can use

 

> `git rebase -i HEAD~X`
> p = pick
> r = reward

 

# Fork and Pull Request

 



 

1. To Fork another repositary from someone GitHub we need go there and choose "fork" then probably we want to clone that repositary to
our local workspace.

 

> `git clone PASTE_URL_HERE`

 

2. How to go into the project

 

> `cd PROJECTNAME/`

 

# Git history

 

1. To check Git history we should use:

 

> `git log`

 

or for example three last commits

 

> `git log --onelone -3`

 

or when we want to see selected authon

 

> `git log --author=AUTHOR_ID`

 

or we can select specyfic dates parameters:

 

> `git log --before "rrrr-mm-dd"`

 

2. Titles of commits

 

> `git log --oneline`

 

> `git log --graph`

 

> `git log --oneline --graph`

 

> `git log --pretty="%H - %aN - %aD"`

 

3. Reflog - local history

 

> `git reflog -NUMBER OD COMMITS`

 

# Pull request

 



 

1. New branch

 

> ` git checkout -b BRANCH_NAME`

 

to send new branch to remotely repo we can use:

 

> `git commit -a -m "message"`

 

Next

 

> `git push --set-upstream origin BRANCH_NAME`

 

# Git rebase & git merge

 



 

# Git squash

 



 

> `git rebase -i COMMIT_ID`

 

and next we need to select -s squash

 

# Git cherry-pick

 



 

> `git cherry-pick COMMIT_ID`

 

# Tagging

 



 

1. Example

 

> `git tag TAG_NAME COMMIT_ID`

 

2. release all tags

 

> `git push --tags`

 

3. Delete tags

 

3.1. Local

 

> `git tag -d TAG_NAME`

 

3.2. Remote

 

> `git push -d origin TAG_NAME`