-
Notifications
You must be signed in to change notification settings - Fork 57
Contributing to 42FileChecker
(to be written)
(to be written)
(to be written)
(to be written)
(to be written)
Rebasing consists in rewriting and/or grouping a number of commits, to make them clean or more explicit. Suppose you have these 5 latest dirty commits in a branch called patch-1
:
git log --oneline
94b2ae8 finally ok
60fdff5 small changes
fd5b463 fix f***ing segfault
6fe7487 use ft_memmove instead of ft_putchar
636da7b first commit
...
We want to group them in a single one commit, and to rename it properly with bug fix: segfault on libft
. First, run git rebase
in interactive mode and specify the number of commits you want to rebase (here is 5):
git rebase -i HEAD~5
HEAD~5
means the last 5 commits from HEAD (the most recent). It opens the editor that is configured for git (vim by default), and displays a list of instructions, one per commit message:
pick 636da7b first commit
pick 6fe7487 use ft_memmove instead of ft_putchar
pick fd5b463 fix f***ing segfault
pick 60fdff5 small changes
pick 94b2ae8 finally ok
The commits are sorted from oldest to newest. The first word of each line is a git command (pick
by default). There are 6 available commands that are described just below in the same screen. Suppose you know what each commit means and that you don't care about what message they contain, the simplest way to group them in a single one and to rename it properly, is to use the command reword
for the first commit (allowing you to change the message) and fixup
for all others (keeping changes trough the first commit but removing the messages), like below:
reword 636da7b first commit
fixup 6fe7487 use ft_memmove instead of ft_putchar
fixup fd5b463 fix f***ing segfault
fixup 60fdff5 small changes
fixup 94b2ae8 finally ok
Now, save and quit the editor, a new editor screen is opened with the first commit message:
first commit
Edit the message properly (the first line is the title of the commit, you can add more info by adding new lines):
bug fix: segfault on libft
that commit fixes a bad behavior in libft resulting in a segfault
Again, save and quit the editor, and let git rebasing! When everything is OK, you get a success message:
Successfully rebased and updated refs/heads/patch-1.
Finally, you must use force push to push to your remote branch because you rewrote the History (note the use of the capital). By default, git will refuse your changes because the local branch does not correspond any more with the remote one. Just run:
git push -f HEAD:patch-1
(Note: Sometimes you could have to resolve conflicts, like with the command git pull --rebase
... a case that should be part of a full other tip)
Introduction:
- What is Bash
- What is a bash script
- What is 42FileChecker
- Contributing to 42FileChecker
Bash syntax:
Bash tools:
- Builtin commands
- Awk
- Cat
- Grep
- Sed
Bash sample codes:
- Script auto-update (git tool)
- Create an interactive menu
- Animated spinner with a time out
- Static var test
- Check the basic rules of a makefile
- Forbidden functions test
- Memory leak test script
- Create a speed test