Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
abregman committed Nov 12, 2022
1 parent 82d1bbe commit 38d13ad
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions resources/git.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Git
# Git

## Learn Git

### Learn Git
Name | Comments
:------|:------:
[git-scm](https://git-scm.com) | The best place (imho) to learn everything about Git (through reading)
Expand All @@ -10,7 +11,7 @@ Name | Comments
[Git for Computer Scientists](https://eagain.net/articles/git-for-computer-scientists/) |
[shortcutfoo](https://www.shortcutfoo.com/app/dojos/git) | interactive learning

### Best Practices
## Best Practices

* Use a descriptive commit message
* Make each commit a logical unit
Expand All @@ -19,26 +20,26 @@ Name | Comments
* Coordinate with your co-workers
* Don't commit generated files

### CheatSheet
## CheatSheet

* Clone a repository: `git clone https://github.com/bregman-arie/devops-resources.git`
* Pull changes from remote repository: `git pull`
* Pull changes without trying to merge the changes between the local branch and the remote one: `git pull --ff-only`

#### Branches
### Branches
* Switch to a branch called "main": `git checkout main`
* Create (if doesn't exists) and switch to a branch called `devel`: `git checkout -b devel`
* List branches: `git branch`
* Update based on status of remote branches: `git remote prune origin`
* Delete local branch: `git branch -d some-branch`
* What are the changes if merging branch y into x: `git merge-tree $(git merge-base x y) x y`

#### Staging
### Staging

* See what the current status in the repository: `git status`
* Add changes to the staging area: `git add <FILE>` or `git add .` to add everything

#### Commits
### Commits
* Create a commit: `git commit`
* List of latest commits: `git log --oneline`
* Push commits to the remote branch: `git push origin main`
Expand All @@ -49,7 +50,11 @@ git revert --no-commit X..HEAD
git commit
```

#### References
### References

* All references in current repository: `find .git/refs/`
* Update master reference: `git update-ref refs/heads/master <SOME_COMMIT>`

### Tags

* Create a new tag: `git tag -a "v0.0.1" -m "First release...yay`

0 comments on commit 38d13ad

Please sign in to comment.