gitGraph commit id: "df21a: Initial commit" tag: "HEAD"
A brief introduction to Git
Git is a skill not a button you press
git-init— Create an empty Git repository or reinitialize an existing one
.git folder for housekeeping data
git-add— Add file contents to the index
.git folder
git-commit— Record changes to the repository
gitGraph commit id: "df21a: Initial commit" tag: "HEAD"
HEAD1gitGraph commit id: "df21a: Initial commit" commit id: "315f2: Update date" tag: "HEAD"
Git has many features that are extensively documented
You will only need a handful of commands in your daily work:
git-config— Get and set repository or global options
You can configure certain (global) settings for your local Git client
For example, you can set the username and mail attached to each commit
The concept of authorship is widely used on platforms, such as GitHub or GitLab
On Levante: module load git
git-branch— List, create, or delete branches
Create a new branch develop to work on a feature
Switch to the new branch (changing the HEAD)
gitGraph commit commit branch develop checkout develop commit commit tag: "HEAD"
git-merge— Join two or more development histories together
gitGraph commit commit branch develop checkout develop commit commit checkout main merge develop tag: "HEAD"
mainmain branchgit branch --help)Collaboration can lead to disagreements1
This creates a conflict when merging both branches
gitGraph commit commit branch alice checkout alice commit checkout main branch bob checkout main merge alice checkout bob commit checkout main merge bob
Solving conflicts requires your decision
Solving conflicts requires your decision
After resolving the conflict1, you have to commit your changes
file.txt in two different branches,main (CONFLICT)Commits should only deal with one task — one logical unit
A single logical unit is not the same as a file
You can use Git to interactively add parts of a file
Write meaningful commit messages
ice: Fix freeing uninitialized pointers
Automatically cleaned up pointers need to be initialized before exiting
their scope. In this case, they need to be initialized to NULL before
any return statement.
Fixes: 90f821d72e11 ("ice: avoid unnecessary devm_ usage")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>Example from kernel.org
You should not commit large (binary) files
Git stores every version of a file in the repository
Binary files are hard to meaningfully compare (diff)
Use a .gitignore file to exclude file patterns:
This lecture is hosted on the DKRZ GitLab
Push your local references to the remote repo
Pull remote changes to your local repo
Push your local references to the remote repo
Pull remote changes to your local repo
ssh-keygen) for use with GitLabI am just gonna throw a bunch of stuff at you. Take what you might find interesting.
— Scott Chacon
git-rebase— Reapply commits on top of another base tip
Instead of merging branches, one can also rebase
%%{init: {'gitGraph': {'showCommitLabel': false}} }%%
gitGraph
commit id: "92664df"
commit id: "39afe64"
branch develop
checkout develop
commit id: "5aeaccd"
commit id: "6c53a8a"
checkout main
commit id: "b125e2f"
%%{init: {'gitGraph': {'showCommitLabel': false}} }%%
gitGraph
commit id: "92664df"
commit id: "39afe64"
commit id: "b125e2f"
branch develop
checkout develop
commit id: "d925af7"
commit id: "dbdb8e4"
Rebasing retains a linear history by changing the commit history (!)
A fork is a copy of a repository on server side
Used to work on public repositories without granting ownership
Standard names for locally defined remotes:
Cloning a repo and it’s submoduels
Update submodules after changing/updating a branch