starts the git bash tutorial

This commit is contained in:
waldek 2022-05-02 22:21:04 +02:00
parent 00ea8253cb
commit 6f2b949408
1 changed files with 144 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# Git # About
Git is a Version Control System. Git is a Version Control System.
It is an advanced open source project. It is an advanced open source project.
@ -12,9 +12,145 @@ You can publish, with all histories, projects in a Git platform like Gitea, GitH
With this tool, you can commit projects, compare projects. With this tool, you can commit projects, compare projects.
That is the best tool for teamwork. That is the best tool for teamwork.
## Git in Pycharm # Git via `bash`
### Starting a version controlled project ## Initialing a git repo
```
waldek@metal:~/Documents/my_first_git_repository$ git status
fatal: not a git repository (or any of the parent directories): .git
waldek@metal:~/Documents/my_first_git_repository$ git init .
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/local/waldek/Documents/my_first_git_repository/.git/
waldek@metal:~/Documents/my_first_git_repository$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add"
```
## What's in this repo
```
waldek@metal:~/Documents/my_first_git_repository$ ls -la
total 12
drwxr-xr-x 3 waldek waldek 4096 May 2 22:06 .
drwxr-xr-x 4 waldek waldek 4096 May 2 22:06 ..
drwxr-xr-x 7 waldek waldek 4096 May 2 22:07 .git
waldek@metal:~/Documents/my_first_git_repository$ ls -la .git/
total 40
drwxr-xr-x 7 waldek waldek 4096 May 2 22:07 .
drwxr-xr-x 3 waldek waldek 4096 May 2 22:06 ..
drwxr-xr-x 2 waldek waldek 4096 May 2 22:06 branches
-rw-r--r-- 1 waldek waldek 92 May 2 22:06 config
-rw-r--r-- 1 waldek waldek 73 May 2 22:06 description
-rw-r--r-- 1 waldek waldek 23 May 2 22:06 HEAD
drwxr-xr-x 2 waldek waldek 4096 May 2 22:06 hooks
drwxr-xr-x 2 waldek waldek 4096 May 2 22:06 info
drwxr-xr-x 4 waldek waldek 4096 May 2 22:06 objects
drwxr-xr-x 4 waldek waldek 4096 May 2 22:06 refs
waldek@metal:~/Documents/my_first_git_repository$
```
## Adding and tracking content
```
waldek@metal:~/Documents/my_first_git_repository$ cat readme.md
# Hello world
I am a paragraph.
I can contain multiple sentences, each on one line.
A blank line separates multiple paragraphs.
1. lists
1. will
1. auto increment in most HTML render engines
* sublists
* are possible
* on multiple
* levels
1. but I keep counting...
```python
print("hello world")
print("I'll be a codeblock...")
```
and [I will become](https://kernel.org) a link.
waldek@metal:~/Documents/my_first_git_repository$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
readme.md
nothing added to commit but untracked files present (use "git add" to track)
waldek@metal:~/Documents/my_first_git_repository$
```
Now we can `add` and `commit` our changes.
```
waldek@metal:~/Documents/my_first_git_repository$ git add readme.md
waldek@metal:~/Documents/my_first_git_repository$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: readme.md
waldek@metal:~/Documents/my_first_git_repository$ git commit -m "adds a readme file"
[master (root-commit) 8278e12] adds a readme file
1 file changed, 22 insertions(+)
create mode 100644 readme.md
waldek@metal:~/Documents/my_first_git_repository$ git status
On branch master
nothing to commit, working tree clean
waldek@metal:~/Documents/my_first_git_repository$
```
We can use `git log` to inspect the list of commits.
Add the `--no-pager` to bypass `less` and print the output straight to the console.
```
waldek@metal:~/Documents/my_first_git_repository$ git --no-pager log
commit 8278e1273d1438920c1063cdca179eb70d5926d8 (HEAD -> master)
Author: waldek <waldek@mailbox.org>
Date: Mon May 2 22:16:50 2022 +0200
adds a readme file
waldek@metal:~/Documents/my_first_git_repository$
```
## The main workflow
1. edit your files
1. `git status` to verify what's new or has been modified
1. `git add` the files you want to commit
1. `git commit -m "A RELEVANT COMMIT MESSAGE"`
1. `git push` to wherever you have your repository
1. repeat step one...
# Git via Atom
# Git via Pycharm
## Starting a version controlled project
In Pycharm, you have to enable a version control integration. In Pycharm, you have to enable a version control integration.
There are many choices, but we will use Git. There are many choices, but we will use Git.
@ -47,6 +183,8 @@ You can see which branch and which commit that you push.
![screenhot](assets/git_pycharm_source_05.png) ![screenhot](assets/git_pycharm_source_05.png)
## Creating an online repository
![screenhot](assets/git_pycharm_source_06.png) ![screenhot](assets/git_pycharm_source_06.png)
![screenhot](assets/git_pycharm_source_07.png) ![screenhot](assets/git_pycharm_source_07.png)
@ -59,7 +197,7 @@ You can see which branch and which commit that you push.
![screenhot](assets/git_pycharm_source_11.png) ![screenhot](assets/git_pycharm_source_11.png)
### Creating an online repository ## Adding some changes to our local code
![screenhot](assets/git_pycharm_source_12.png) ![screenhot](assets/git_pycharm_source_12.png)
@ -73,7 +211,7 @@ You can see which branch and which commit that you push.
--> -->
### Cloning the remote project into a new project ## Cloning the remote project into a new project
![screenhot](assets/git_pycharm_clone_00.png) ![screenhot](assets/git_pycharm_clone_00.png)
@ -97,7 +235,7 @@ You can see which branch and which commit that you push.
--> -->
### Updating the original project ## Updating the original project
![screenhot](assets/git_pycharm_source_18.png) ![screenhot](assets/git_pycharm_source_18.png)