-
Notifications
You must be signed in to change notification settings - Fork 6
Minimum guide for main git commands
git clone https://github.com/KhiopsML/khiops.git
pre-commit install
: to format the files
git branch --all
: to see all branches on your local repo
git switch branch_name
: to switch to your branch
git status
show usefull info: current branch, and current status of modified files
- manage the files to be added to the commit
git add -u
: to take into account all updates filesgit add file_name
: to add a specific filegit mv file_name new_file_name
: to rename a file
git commit
git push
: to update to central repo
- Commit message
- first line is the title, and it should short explaining the What the commit does
- followed by an empty line, and then detailed comments if necessary
- good practise: use your IDE to check your changes and write a synthetic summary
- Updating previous commit for a minor change (ex: typo)
git commit --amend
git commit --amend --no-edit
: idem, without update the commit messagegit push --force
: required to force the update of the central repo after the amend
You may want to refresh a branch if its origin has been updated since the branch was developed.
You thus need to rebase your branch branch-name
on dev
to get the last version of the source
- refresh the local repo on dev
git switch dev
git pull
- take into account the last commit of dev
git switch branch-name
git rebase dev
- resolve conflicts and make a commit again
- Prerequistes:
- first, rebase your branch
branch
ondev
to get the last version of the source - tests on the standard family will be carried out automatically using CICD
- for major pull requests, may require all LearningTest non-regression tests to be verified
- first, rebase your branch
git log
git log --oneline
: with titles only
git log -n
: last n commits:
gitk
: show log in UI mode
git log -p file_name
: show last updates in shell mode
gitk file_name
: in UI mode
Need: periodically save the current branch, even if it has not reached a stable state
- make temporary commits, with the commit message prefixed with WIP (work in progress)
- push tehm to save them on the central repo
- once development has stabilised, merge these temporary commits into a single commit (squash)
cf.
https:\www.ekino.fr\publications\how-to-squash-efficiently-its-commits-with-git\
- First of all, you need to get the sha1 (commit_hash) of the commit preceding the one you are going to squash
- using
git log --oneline
- using
- then use it to run the command:
git rebase -i commit_hash
- You then enter interactive mode (using the git editor).
- Commits are displayed from the oldest to the most recent.
- The first commit is the basic one, the one you want to keep; so leave the "pick" instruction in front of it.
- We want to squash all subsequent commits, so we put the "squash" instruction in front of them.
- In concrete terms, we tell GIT to base itself on the first commit and we apply all the subsequent commits to make just one.
- When you validate the squash (you leave interactive mode), Git will re-apply the commits in the same order as they were configured just before. We then put in a commit message relating to the grouping of our commits (from the messages for the relevant commits) and that's all.
- First of all, you need to get the sha1 (commit_hash) of the commit preceding the one you are going to squash
- When the final commit is pushed, you need to force it:
git push --force