# Git 101

### [Official Documentation](https://git-scm.com/docs/git)

* What is a modern VCS i.e git
* How is it different from the ABAP version management

### Traditional Version Control System:

Check out file --> Modify --> Check in new version

### Decentralized Version Control System:

Everyone has local copy --> Modify and upload to master version control

### GIT Flow:

![](/files/zRNq1vFjJo0LUQed1UT6)

### GIT Steps:

```bash
0. git pull
1. git add
2. git commit -m "message to the moon"
3. git push
4. git pull
```

### How to install, configure a repo and use GUI or cmdline to manage a project

* [GIT-BASH](https://git-scm.com/download/win)

```bash
git config --global user.name 'myuser'
git config --global user.email 'myemail@mydomain.com'
git add -h (better than --help)
```

### Either/Or

1. Local codebase to git (uncommon -it's usually the second option below)

```bash
git init
git status (--short)
touch .gitignore
git add -A
git reset && git status || git rm --cached ONEFILE && git status
```

2\. Git repo to local (common -like hypeyledgy. You're already a developer with access to a project. Code away after you clone it. )

```bash
git clone <url> dir
git remote -v
git branch -a
git pullorigin master ( !! Always check you're on latest version with a pull !! )
git pushorigin master
git diff --staged ( after a git add )
git commit -a -m " git add & git commit in one! "
```

### Nitty gritty and useful

```bash
git log -p --since=" 2 weeks ago "
Pages 1-100 Page 3
git log -p --since=" 2 weeks ago "
git log -S "codethatisbroken" (the grep)
git commit --amend
git checkout --file ## revert modified file to original
git remote -v
git remote add projectos <url>
git remote show origin
git fetch <url>
git checkout sha-1 . || git reset --hard [sha-1]
```

### Branches

```bash
git branch vladut-bugfix
git checkout vladut-bugfix
git push-uorigin vladut-bugfix
```

### Shortcuts

```bash
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git mv permissions2.txt permissions.acl
git status
git commit -m "fixed filesname"
git push origin master
```


---

# 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://docs.arkannis.net/devops/git/git-101.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.
