A Brief Introduction into Git
There are many version control systems out there (e.g. Subversion, CVS, Mercurial). We will focus on Git which is the de facto standard
git init . # Initialize a repository
git add . # Add the whole directory content (don't do that)
git commit -m "Initial commit" # Commit your changes
Commits are linked to form a sequence of snapshots:
Git offers plenty of functionality that is extensively documented
You will only need a handful of commands in your day to day work:
Each commit is attributed to an author
The concept or authorship is heavily used on other platforms (e.g. GitLab)
On Levante: module load git
Create a branch develop
to work on a feature
Merge the commits of develop
into main
main
branchgit branch --help
)Collaboration can lead to disagreements
This creates a conflict when merging both branches
Solving conflicts requires your decision
Solving conflicts requires your decision
file.txt
in two different branches with different contentmain
(CONFLICT
)Commits should deal with only one task; one logical unit
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
Adding a remote repository
List the available remotes
Push your local references to the remote repo
Pull remote changes to your local repo
main
https://gitlab.dkrz.de/generic-software-skills/students2024/<YOUR_USERNAME>.git
Instead of merging branches, one can also rebase
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:
VSCode, meld