Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Tool - Git #393

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tools/git/about.md
Original file line number Diff line number Diff line change
@@ -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


176 changes: 176 additions & 0 deletions tools/git/git-basic-usage.md
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd reword this to sounds more certain.

Suggested change
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.
Open up a terminal in a directory where you want to clone the repository into. Execute the following command (with additional parameters if needed to accommodate custom-named SSH keypair files) to clone the repository.

Does not seem like forked repo that we are cloning here.

Also, the first time I am hearing about custom-named SSH keypair files in relation to git clone. (git manages to pull out the correct ones for me anyway)
Would you mind writing a few sentences about the additional parameters?


```
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am quite lost in reading this; I tried to approximate what you probably meant at the time of writing, but please recheck my suggestion if it is truly correct. Also, fixed usage of a space after a dot in a sentence.

Suggested change
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.
Let’s go through a simple example of a branching workflow that you might use in the real world. First, create a new branch in our repository. Name it appropriately, for instance, a branch describing the work you are doing on 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrite for conciseness.

Suggested change
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.
After making changes to the files, execute the following command to list the modifications in the tracked files and list untracked files if there are any.


```
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Stage similar changes by executing the following command to prepare them to be committed. Please note that multiple changed files can be staged for a single commit, but it is strongly recommended to keep dissimilar changes as separate commits.


```
git add <file-that-was-changed>
```

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 "<appropriate-commit-message>"
```

## 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 <branch-name-according-to-what-would-be worked-on>
```

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 <branch-name-according-to-what-would-be-worked-on>
```

## 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you already have branch in your computer your can just pull via "git pull"
If you already have a branch in your computer you can just pull via "git pull"

Hmm, branch in your computer does not sound right. Maybe in your local repository is better?


```
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain what does the switch -t mean/do.

```

## 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
```
42 changes: 42 additions & 0 deletions tools/git/git-configuration.md
Original file line number Diff line number Diff line change
@@ -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 "<your-email-address>"
```

Setting up your git commit username(nickname or your name) globally

```
git config --global user.name "<your-full-name>"
```

Setting up your `core.editor`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please list some examples of what is git using the editor for. Like git commit and other commands that need manual intervention.


```
git config --global core.editor vim
```

It can be change various editors such as `emacs`,`vi`,`nano`,`neovim`,`Kate` and more
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It can be change various editors such as `emacs`,`vi`,`nano`,`neovim`,`Kate` and more
Various editors such as `emacs`, `vi`, `nano`, `neovim`, `Kate` and more can be used.


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)