# Git\&Github

#### Git initialize repository

```
git init your_folder_name
```

#### Git add all changes to staging area

```
git add .
```

#### Git commit change with log message

```
git commit -m "your_message"
```

#### Git view all commits

```
git log --oneline --all
```

#### Git create alias command

```
git config --global alias.hist “log --oneline --all”
```

#### Git checkout all alias

```
git config --global --list
```

#### Git view a commit history

```
git checkout commit_hash_code
```

#### Git undo changes that are not staged

```
git restore file_want_to_backout
```

#### Git undo changes that are staged

```
git reset HEAD file_want_to_backout
```

#### Git undo the last commit

```
git reset --hard HEAD^
```

#### Git clean untracked file

```
git clean -fd
```

#### Git create branch

```
git checkout -b your_branch_name
```

#### Git merge branch

```
git merge your_branch_name
```

#### Git push changes to remote

```
git push origin branch_name(master or your_own_branch_name)
```

#### Git update local with remote repository

```
git pull
```

#### Git remove the last commit remotely

```
git reset --hard HEAD^
git push origin +master
```

#### Git config username and email

```
git config --global user.name "Juechen"
git config --global user.email "xxx@gmail.com"
```

#### Git add and commit alias

```
git config --global alias.cm '!git add -A && git commit -m'
```

#### Skip the login step when doing push/pull

```
git config --global credential.helper store
```

#### Git add existing project to remote

```
git remote add origin https://github.com/juechenyang/FusionProject.git
```

#### Generate SSH key windows

```shell
ssh-keygen -t ed25519 -C "your_email@example.com"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://juechen-yang.gitbook.io/juechen-s-codebook/git-and-github.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
