Skip to content

Cygnus-Software/intro-git

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 

 

Index

 

Introduction to Git

What is "Git"?

Git is the main version control system used in the world. Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.

This provides many advantages like multiple people working on the same project asynchronously, testing changes to a system without having to worry about reverting to a previous state if necessary, compare changes in files, maintaining different versions of the same system on the same place but separate, keep a history of changes for future reference, among others.

Git Official page

Instalation

Debian/Ubuntu:

apt-get update
apt-get install git

Arch Linux:

pacman -S git

Other Distributions


Remote repositories

It is entirely possible to work with git locally on your machine without other contributors, since some of the benefits of git are keeping track of changes in time, so to clarify there's a separation between git and platforms like GitHub, GitLab, or Bitbucket; but teams and companies always work with remote repositories, and developing alone makes it so you never run into some of the problems git is great at solving, so it is important to understand how to work with those as well.

What is GitHub, GitLab and Bitbucket?

They are all platforms that provide internet hosting for version control using Git. They also provide further tools for software development management like source code management, access management, bug tracking, feature requests, task management, continuous integration and documentation hosting, to name a few.

They let you upload code either publicly or on private repositories and integrate with git to use its many benefits.

Git commands

Configuration

View config

git config --list

Start

Clone a existing project

Once you have the repository url you clone it (which will download its main/master branch) with:

git clone <repository-url>

This will create a folder with the repository name wherever you are. If you want to specify a path or a folder name, simply add it as a argument:

git clone <repository-url> /path/to/git_folder

Create a git project from scratch

Go to the directory with the project code (or an empty directory to start from zero) and run:

git init

This will create a new project where all files and subfolders are

git remote set-url origin https://github.com/Cygnus-Software/intro-git.git

Note: The remote url is generally the https repository url with a .git at the end

Create a new local repository


Commit Changes

git status

Add a commit

git commit -m "Tittle commit example" -m "Commit description"

Show a commit

git show <tag_commit>

Add local changes to repository

git add

Delete the file from

Branches

Create a new branch

git branch <name_branch>

Switch to another branch and check it out into your working directory

git checkout <name_branch>

Commit history

Show all commits in the actual branch and all files

git log

Show all changes for a specific file

git log -p <file>

Diff of what is changed but not staged

git diff

Commit your staged content as a new commit snapshot

git diff --staged

Undo

Discard all local changes

git reset --hard

Tags

Add a tag in current branch

git tag <tag-name>

Errors

Please use a personal access token instead

Get Token

[user@Cygnus Cygnus_intro_git]$ git push origin develop
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: unable to access 'https://github.com/Cygnus-Software/intro-git.git/': The requested URL returned error: 403
git config --global --unset credential.helper

Git PURR!

Credits to Tomomi Imura

Purr pull

Purr Merge and rebase

Purr push

Purr log

Other tools and tips

Add co author

How to add co-author

Graph

sudo apt install gitk

GUI Clients

What is a "GUI" for git?

https://git-scm.com/download/gui/linux

Visual Studio Code: extensions

Pair programming Live-Share


References

Readme in other languages

README ES

Contributors