Rename language articles

This commit is contained in:
Angelos Chalaris
2023-05-18 23:57:15 +03:00
parent 45d1fa023a
commit 2d58c1dfd7
48 changed files with 17 additions and 17 deletions

52
snippets/git/s/aliases.md Normal file
View File

@ -0,0 +1,52 @@
---
title: Git aliases
type: cheatsheet
language: git
tags: [configuration,cheatsheet]
author: chalarangelo
cover: compass-1
excerpt: Increase your productivity by creating aliases for many common git operations.
dateModified: 2021-06-12T19:30:41+03:00
---
### Creating aliases
Use the command below to create aliases, replacing `<alias>` with the name of the alias and `<command>` with the command to be aliased:
```shell
git config --global alias.<alias> <command>
```
Additionally, you can use [edit the configuration file](/git/s/edit-config) and add many aliases all at once.
### Useful aliases
```editorconfig
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
st = status
aa = add -A .
unstage = reset --soft HEAD^
cm = commit -m
amend = commit --amend -m
fix = commit --fixup
undo = reset HEAD~1
rv = revert
cp = cherry-pick
pu = !git push origin `git branch --show-current`
fush = push -f
mg = merge --no-ff
rb = rebase
rbc = rebase --continue
rba = rebase --abort
rbs = rebase --skip
rom = !git fetch && git rebase -i origin/master --autosquash
save = stash push
pop = stash pop
apply = stash apply
rl = reflog
```

View File

@ -0,0 +1,21 @@
---
title: "Tip: Create a commit with a different date"
shortTitle: Create a commit with a different date
type: tip
language: git
tags: [commit]
author: chalarangelo
cover: ice
excerpt: Ever needed to create a git commit with a different date? Here's a quick and easy way to do it.
dateModified: 2021-06-12T19:30:41+03:00
---
Sometimes, you might run into a situation where you need to create a commit with a different date than the current one. Luckily, you can handle this using `GIT_AUTHOR_DATE` and `GIT_COMMITTER_DATE`:
```shell
GIT_AUTHOR_DATE='Mon May 18 19:32:10 2020 -0400' \
GIT_COMMITTER_DATE='Mon May 18 19:32:10 2020 -0400'\
git commit -m 'Commit from the past'
```
As shown in the example above, you can set both values to any date you like and your code will be committed on that date. Note that the format for the values above is `'date +"%s %z"'`, also referred to as internal raw git format, but you can also use other formats, such as RFC 2822 (`'Mon, 18 May 2020 19:32:10 -0400'`), ISO 8601 (`'2020-05-18 19:32:10 -0400'`), local (`'Mon May 18 19:32:10 2020'`), short (`'2020-05-18'`) or relative (`5.seconds.ago`, `2.years.3.months.ago`, `'6am yesterday'`).

View File

@ -0,0 +1,25 @@
---
title: How does Git's fast-forward mode work?
shortTitle: Git fast-forward
type: question
language: git
tags: [branch]
author: chalarangelo
cover: boats
excerpt: Learn about Git's fast-forward mode works and its benefits when mergin branches, so you can decide if it's a good fit for you and your team.
dateModified: 2021-07-15T05:00:00-04:00
---
Merging a branch is one of the most common operations when working with Git. Depending on your team and projects you've been a part of, you might have heard of or even used Git's **fast-forward** mode when merging. Fast-forward mode is the default in Git, however GitHub will essentially override this by default and create a merge commit instead.
![Git fast forward explained](./illustrations/git-fast-forward.png)
### Fast-forward merge
As stated above, Git's default is to use fast-forward merge. It will take the commits from the branch being merged and place them at the tip of the branch you're merging into. This creates a **linear history**, which is also the main advantage of using fast-forward merge. If you want to emulate fast-forward merge on GitHub, you can use the "Rebase and merge" option.
### Non fast-forward merge
GitHub, on the other hand, uses non fast-forward merge by default. It will create a merge commit at the tip of the branch you're merging into, optionally referencing the branch being merged in the commit message. This has the advantage of **keeping track of branches** more explicitly than fast-forward merge. If you want to get the same behavior in a Git terminal, you can use the `--no-ff` flag.
As a side note, you can configure the default Git merge behavior, using `git config`. To learn how to do so, you can take a look at the [relevant snippet](/git/s/disable-fast-forward).

View File

@ -0,0 +1,27 @@
---
title: "Tip: How to add multiple authors to a commit"
shortTitle: Add multiple authors to a commit
type: tip
language: git
tags: [github,programming,webdev]
author: chalarangelo
cover: book-chair
excerpt: Learn how to add multiple authors to a git commit with this quick and easy tip.
dateModified: 2021-06-12T19:30:41+03:00
---
You can add multiple authors to a git commit, by adding one or more `Co-authored-by` trailers to the commit's message:
```shellsession
$ git commit -m "Refactor usability tests.
>
>
Co-authored-by: name <name@example.com>
Co-authored-by: another-name <another-name@example.com>"
```
### Notes:
- To correctly attribute a commit to a co-author, you must use the email associated with their GitHub account.
- If a person's email is private, you can use their GitHub-provided `no-reply` email.
- Leave one or preferably two empty lines before any `Co-authored-by` trailers.