|
|
# **git** cheat sheet
|
|
|
## Only the first time
|
|
|
* install [**```git```**](https://git-scm.com/download/)
|
|
|
* set email adress: ```git config --global user.email "meep@meep.com"``` (has to be the email you used in *github.com*)
|
|
|
* set name: ```git config --global user.name "meep meep"```
|
|
|
* install [**git**](https://git-scm.com/download/)
|
|
|
* set email adress:
|
|
|
```bash
|
|
|
git config --global user.email "meep@meep.com"
|
|
|
```
|
|
|
(has to be the email you used in *github.com*)
|
|
|
* set name:
|
|
|
```bash
|
|
|
git config --global user.name "meep meep"
|
|
|
```
|
|
|
|
|
|
### **Clone a repo:**
|
|
|
* **clone** the repo: ```git clone https://github.com/*your_name*/Python_course.git```
|
|
|
* **clone** the repo:
|
|
|
```bash
|
|
|
git clone https://github.com/*your_name*/Python_course.git
|
|
|
```
|
|
|
|
|
|
### **Fork a repo:**
|
|
|
* Go to [github.com](https://www.github.com/) to the [page](https://github.com/tbphu/Python_course) of the repo and press the fork button.
|
|
|
* Then clone the repo from **your** github account ```git clone https://github.com/*your_name*/Python_course.git```
|
|
|
* Go into your local repo ```cd Python_course```
|
|
|
* set **upstream**: ```git remote add upstream https://github.com/tbphu/Python_course.git```
|
|
|
* Then clone the repo from **your** github account
|
|
|
```bash
|
|
|
git clone https://github.com/*your_name*/Python_course.git
|
|
|
```
|
|
|
* Go into your local repo
|
|
|
```bash
|
|
|
cd Python_course
|
|
|
```
|
|
|
* set **upstream**:
|
|
|
```bash
|
|
|
git remote add upstream https://github.com/tbphu/Python_course.git
|
|
|
```
|
|
|
|
|
|
## Daily work with git
|
|
|
* **pull** repo: ```git pull```
|
|
|
* **add** file: ```git add ./filename```
|
|
|
* **commit**: ```git commit -m "I have done this and that" ./meep.py```
|
|
|
* **push** commits: ```git push```
|
|
|
* **merge** commits: ```git merge```
|
|
|
* check **status** of repo: ```git status```
|
|
|
* **delete uncommited** changes: ```git checkout .```
|
|
|
* **pull** repo:
|
|
|
```bash
|
|
|
git pull
|
|
|
```
|
|
|
* **add** file:
|
|
|
```bash
|
|
|
git add ./filename
|
|
|
```
|
|
|
* **commit**:
|
|
|
```bash
|
|
|
git commit -m "I have done this and that" ./meep.py
|
|
|
```
|
|
|
* **push** commits:
|
|
|
```bash
|
|
|
git push
|
|
|
```
|
|
|
* **merge** commits:
|
|
|
```bash
|
|
|
git merge
|
|
|
```
|
|
|
* check **status** of repo:
|
|
|
```bash
|
|
|
git status
|
|
|
```
|
|
|
* **delete uncommited** changes:
|
|
|
```bash
|
|
|
git checkout .
|
|
|
```
|
|
|
* **update forked** repo:
|
|
|
```git fetch upstream```
|
|
|
```git merge upstream/master```
|
|
|
```bash
|
|
|
git fetch upstream
|
|
|
```
|
|
|
```bash
|
|
|
git merge upstream/master
|
|
|
```
|
|
|
|
|
|
## Merge messages
|
|
|
Usually, after the ```git merge```, git will open a text editor where you can type in a **commit message**, git suggests a message like ```Merge branch 'master' of https://www.github.com:*yourname*/Python_course.git```. That is the description of your commit. In Windows, this should be ***notepad*** which is pretty easy to handle. In the Linux terminal, the text editors can be a bit more difficult to handle because they work only with keyboard and not with a mouse.
|
|
|
Usually, after the `git merge`, git will open a text editor where you can type in a **commit message**, git suggests a message like ```Merge branch 'master' of https://www.github.com:*yourname*/Python_course.git```. That is the description of your commit. In Windows, this should be ***notepad*** which is pretty easy to handle. In the Linux terminal, the text editors can be a bit more difficult to handle because they work only with keyboard and not with a mouse.
|
|
|
|
|
|
**nano** looks like this:
|
|
|
[[nano.png | height = 250px]]
|
|
|
<img src="nano.png" height="300">
|
|
|
To exit it you have to press **```<Strg>+O```** to save and **```<Strg>+X```** to exit
|
|
|
|
|
|
**vi** looks like this:
|
|
|
[[vi.png | height = 250px]]
|
|
|
<img src="vi.png" height="300">
|
|
|
To exit it you have to press **```<Esc>```** than **```:wq```** to save and quit |
|
|
\ No newline at end of file |