+91 9619904949

Git is free and open source software for distributed version control: tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows (thousands of parallel branches running on different systems).

Git was originally authored by Linus Torvalds in 2005 for the development of the Linux kernel, with other kernel developers contributing to its initial development. Since 2005, Junio Hamano has been the core maintainer. As with most other distributed version control systems, and unlike most client-server systems, every Git directory on every computer is a full-fledged repository with complete history and full version-tracking abilities, independent of network access or a central server. Git is free and open-source software distributed under the GPL-2.0-only license.

Characteristics:-
Strong support for non-linear development
Distributed development
Compatibility with existing systems and protocols
Efficient handling of large projects
Cryptographic authentication of history
Toolkit-based design
Pluggable merge strategies
Garbage accumulates until collected
Periodic explicit object packing

* remote server = Linux system in the cloud
* client = local computer(window, Linux, Mac)

1

yum -y install git

For install Git

Install git on the remote server and On the client.

2

git –version

check the currently installed git version

3

git config –global user.name ‘Nitwings Server’

git config –global user.email ‘[email protected]

Set a repository username and email to identify where to push or pull code from.

Set on remote Server.

4

git config –global user.name ‘Anil Jalela’

git config –global user.email ‘[email protected]

Set a repository username and email to identify where to push or pull code from.

On client.

5

git config -l

list of information about git configuration including user name and email

On client and server.

6

mkdir /home/git-client.blackpost.net/public_html/repos/project-client

Creating Git repository Folder

On client.

7

git init

Initialize Git repository

On client.

8

mkdir /home/git-server.blackpost.net/public_html/repos/project-server

Initialize Git repository

On Server.

9

git init –bare

Initialize Git repository

On Server.

10

echo “Hello Nitwings” > /home/git-client.blackpost.net/public_html/repos/project-client/index.html

create 1st file in an empty repository

On client.

11

git status
git status –short

to check git status use the command “git status”

On client.

12

git add index.html

Add index.html in the current directory to the Staging Environment

On client.

13

git add –all

Add all files in the current directory to the Staging Environment

On client.

14

git add -A

git add .

Add all files in the current directory to the Staging Environment

On client.

15

git commit -m “this is our 1st project release”

Move from Staging to commit for our repo(master repo) when work is done.

-m = message

On client.

16

git commit -a

commit file directly in a master repo without adding a stage repo

17

git log

view master repo history for commits

18

git –help

For git help

–help instead of -help to open the relevant Git manual page

19

git help –all

or

git help –a

To list all possible commands

20

git add –help

git command -help

21

git branch branch-name

Create git branch

(brach create in same repo dir)

22

git branch

Show branch in the repo

23

Git checkout ‘branch-name’

Switched to branch

in branch working dir is same.

24

git checkout -b ‘fastfix’

Create fast-fix branch and use it for changes

25

git checkout master
git branch

Switched to branch ‘master’
and show all branch

26

git merge ‘fastfix’

merge the selected branch (master) with not selected branch name

27

git branch -d fastfix

Delete fast-fix branch

28

Git log

View the history of commits for the repository

29

touch .gitignore

git add .gitignore

git commit .gitignore

Create .gitignore file

and add and commit to ignoring some files and folders from the workspace

Vi .gitignore

*.txt

In .gitignore add a line to ignore all .txt files

30

Vi .gitignore

rndcode/

In .gitignore add a line to ignore all files in any directory named rndcode

31

Vi .gitignore

*.bat

!server.bat

In .gitignore, ignore all .bat files, except the server.bat

32

git log –oneline

Show the log of the repository, showing just 1 line per commit

33

git show commit-id

34

git log -10

35

git log –grep “word”

36

git stash

37

git stash list

38

git stash apply staash@{file number}

39

git stash clear

40

git reset file-name

41

git reset .

42

git reset –hard

43

git clean -n

44

git clean -f

45

git tag -a tagname -m “message” commit-id

46

git tag

git show tag-name

47

git -d tag tag-name

GitHub or Your Server Repo:-

git remote add origin github-url

Add a remote repository as an origin

Git fetch origin

Get all the change history of the origin for this branch

git merge origin/master

Merge the current branch with the branch master, on the origin

git  pull origin

Update the current branch from its origin using a single command

git pull origin master

Update the current branch from the origin master using a single command

git push origin

push the current branch to its default remote origin

git push origin master

push the current branch to its default remote maser

Git branch -a

List all local and remote branches of the current Git

Git branch -r

List only remote branches of the current Git

git clone url

Clone the remote repository

git clon url project-client

Clone the repository https://blackpost.net/wings.git to a folder named “project-client“:

Git remote rename origin upstream

Rename the origin remote to upstream

git remote add ssh-origin user@blackpostnet:/git-reo-path/

Add a remote repository via SSH as an origin

Git remote set-url origin user@blackpostnet:/git-reo-path/

Replace remote origin URL

What needs to learn in Git?

Introduction 
‌      Understanding version control
‌      The history of Git 
‌      About distributed version control 
‌      Who should use Git? 
‌      Installing Git on Windows
‌      Installing Git on Linux 
‌      Configuring Git 
‌      Exploring Git auto-completion
‌      Using Git help 
Initializing a repository 
‌      Understanding where Git files are stored
‌      Performing your first commit
‌      Writing commit messages      
‌      Viewing the commit log 
Exploring the three-trees architecture 
‌      The Git workflow
‌      Using hash values (SHA-1)
  ‌    Working with the HEAD pointer 
Adding files
‌      Editing files
‌      Viewing changes with diff
‌      Viewing only staged changes 
‌      Deleting files
‌      Moving and renaming files 
Undoing working directory changes
‌      Unstaging files
‌      Amending commits
‌      Retrieving old versions
‌      Reverting a commit 
‌      Using reset to undo commits
‌      Demonstrating a soft reset
‌      Demonstrating a mixed reset
‌      Demonstrating a hard reset
‌      Removing untracked files 
Using gitignore
‌      Understanding what to ignore
‌      Ignoring files globally
‌      Ignoring tracked files
‌      Tracking empty directories 
Referencing commits 
‌      Exploring tree listings
‌      Getting more from the commit log
‌      Viewing commits
‌      Comparing commits 
Branching overview 
‌      Viewing and creating branches
‌      Switching branches
‌      Creating and switching branches
‌      Switching branches with uncommitted changes
‌      Comparing branches
‌      Renaming branches 
‌      Deleting branches 
‌      Configuring the command prompt to show the branch 
Merging code
‌      Using fast-forward merge vs true merge
‌      Merging conflicts
‌      Resolving merge conflicts 
‌      Exploring strategies to reduce merge conflicts 
Saving changes in the stash
‌      Viewing stashed changes
‌      Retrieving stashed changes
‌      Deleting stashed changes 
Working with GitHub
‌      Setting up a GitHub account
‌      Adding a remote repository
‌      Creating a remote branch
‌      Cloning a remote repository
‌      Tracking remote branches
‌      Pushing changes to a remote repository
‌      Fetching changes from a remote repository
‌      Merging in fetched changes
‌      Checking out remote branches
‌      Pushing to an updated remote branch
‌      Deleting a remote branch
‌      Enabling collaboration
‌      A collaboration workflow
‌      Using SSH keys for remote login
‌      Managing repo in GitHub
‌      Managing users in GitHub
‌      Managing keys in GitHub
‌      Webhook in GitHub ‌

Next update soon…