diff --git a/tools/git/about.md b/tools/git/about.md new file mode 100644 index 00000000..3757c822 --- /dev/null +++ b/tools/git/about.md @@ -0,0 +1,46 @@ +--- +title: Git +subsection: git +section: tools +description: Create reproducible and portable development environments that can be easily shared in your team. + +order: 1 +--- + +# Git + +[Git](https://git-scm.com/) is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. + +## Installing Git on Fedora + +On Fedora install the git package: + +``` +$ sudo dnf install git +``` + +Or you can install meta-package to pull in all git tools: + + +``` +$ sudo dnf install git-all +``` + + +## Git tools/plugins + +Git can be extended by plenty of plugins, some of them are even packaged in +Fedora. Some of them gives you ability use git via web or gui interface or extend default git ability + +* git-cvs - Git tools for importing CVS repositories +* git-daemon - Git protocol daemon +* git-gui - Graphical interface to Git +* git-subtree - Git tools to merge and split repositories +* gitk - Git Repository Browser (GUI) +* gitweb - Simple web interface to git repositories +* git-email -Git tools for sending patches via email +* git-svn - Git tools for interacting with Subversion repositories +* git-instaweb - Repository browser in gitweb +* git-cola - A sleek and powerful git GUI + + diff --git a/tools/git/git-basic-usage.md b/tools/git/git-basic-usage.md new file mode 100644 index 00000000..08303b6d --- /dev/null +++ b/tools/git/git-basic-usage.md @@ -0,0 +1,176 @@ +--- +title: Git Basic Usage +subsection: git +order: 2 +--- + +# Basic Git Usage + + +## Cloning Git Repository +Open up a terminal in a directory where the repository would be cloned. Execute the following command (with additional parameters if needed to accommodate custom-named SSH keypair files) to clone the fork repository. + +``` +git clone https://src.fedoraproject.org/rpms/hello.git +``` + +Navigate into the cloned repository and feel free to pick an IDE and code editor of your choice to start working on the code. + +## What is git-branch ? + +A Git branch is a version of the repository that diverges from the main working project. It is a feature available in most modern version control systems. A Git project can have more than one branch. + + +## Listing Branches + +Listing a branch in Git is simple. + + +Show local branch(es) +``` +git branch +``` + +Result: + +``` +* master +foo-branch +foo-branch-2 +``` + +Show All branch(es) including local branches + +``` +git branch -a +``` +Result: + +``` + master + foo-branch + foo-branch-2 + remotes/origin/HEAD -> origin/master + remotes/origin/master + remotes/origin/foo-branch + remotes/origin/foo-branch-2 + remotes/origin/foo-branch-3 + +``` + +## Creating Branches + +Let’s go through a simple example of branching workflow that you might use in the real world.Once create new branch it will give us current branch we have in our repository.Give it a name appropriately. For instance, a branch consisting of work you doing it. + + + +Create branch +``` +git branch branch-foo +``` + +Switch to new branch + +``` +git checkout branch-foo +``` + +Create and switch to new branch (shorthand) + +``` +git checkout -b branch-foo +``` + +#### Useful Tip +* Be sure to NOT work on the primary branch of the repository, which is `master` in this case. Keep the primary branch aside as a reference branch to create new branches out of and fallback to in case of scrapping. For example If you work on something like "foo-feature" you should name your branch `foo-feature`. + +``` +git checkout -b foo-feature +``` + +## Git Status + +After on the working on the code, execute the following command to know about the changes made with additions, removals and modifications made in the tracked and untracked files. + +``` +git status +``` + +## Git Add + +Stage the changes of similar kind by executing the following command to prepare them to be committed. Please note that multiple changed files can be staged for single commit, but it is strongly recommended to keep dissimilar changes as separate commits. + +``` +git add +``` + +Stage all changes at once + +``` +git add . +``` + +## Git Commit + +Commit the staged changes to the checked out branch of your locally. The commit message should be representative of the changes made in the said commit and preferably be under 50 chars. + +``` +git commit -sm "" +``` + +## Git Push + +In order to reflect the locally made changes to your remote fork, the changes must be pushed. If there is no upstream branch available for the currently checked out local branch - which is generally the case when new branches are created locally, push can be made by executing the following command. + +``` +git push --set-upstream origin +``` + +Once an upstream branch is available for the currently checked out local branch - which is generally the case after the above command has been executed, push can be made by executing the following command. + +``` +git push origin +``` + +## Git Pull + +There are cases you want to view some changes wich are already in your fork (e.g. modified using Github WebUI). We're using variables holding your remote and branch names: + +If you already have branch in your computer your can just pull via "git pull" + +``` +# Pulls curent branch commits from remote +$ git pull +``` + +If you don't have remote branch in your computer then you can fetch the changes from your fork: + +``` +$ git fetch remote-branch +``` + +And then checkout the branch: + +``` +$ git checkout -b new-branch-name -t $remote/$branch +``` + +## Git Rebases + +To update the `foo/` directory, switch to that directory, make sure you are on your development branch and rebase on the latest stuff: + +``` +$ cd foo +$ git checkout my-devel-branch +$ git fetch origin +$ git rebase origin/master +``` + +If conflicts occured, you need to resolve them, and continue with rebase. + +``` +$ nano file/that/has/conflict.md +# properly adjusted / edited to show correct foo-content +$ git add file/that/has/conflict.md +$ git rebase --continue +``` \ No newline at end of file diff --git a/tools/git/git-configuration.md b/tools/git/git-configuration.md new file mode 100644 index 00000000..9c52b251 --- /dev/null +++ b/tools/git/git-configuration.md @@ -0,0 +1,42 @@ +--- +title: Configuring Git +subsection: git +order: 3 +--- + +# Configuring Git + +The git can be extensively configured. + +## Basic configuration + +Set the author identity by saving the name and email address with the following command. Execute without the `--global` flag if the identity is to be retained only for the current repository. + + +Setting up your git commit e-mail adresses globally + +``` +git config --global user.email "" +``` + +Setting up your git commit username(nickname or your name) globally + +``` +git config --global user.name "" +``` + +Setting up your `core.editor` + +``` +git config --global core.editor vim +``` + +It can be change various editors such as `emacs`,`vi`,`nano`,`neovim`,`Kate` and more + +For more information about changing `core.editor` config please check out [Appendix C: Git Commands - Setup and Config](https://git-scm.com/book/en/v2/Appendix-C%3A-Git-Commands-Setup-and-Config) + + + +## More customizible settings + +Please check out [Customizing Git - Git Configuration](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration)