Git Tutorial

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

Microsoft Windows [Version 10.0.22000.

1696]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Argha>cd \

C:\>git
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[--config-env=<name>=<envvar>] <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)


clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)


add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status

grow, mark and tweak your common history


branch List, create, or delete branches
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Reset current HEAD to the specified state
switch Switch branches
tag Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)


fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

C:\>cd gittest

C:\gittest>git clone https://github.com/argharaha/StudyProjects.git


Cloning into 'StudyProjects'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 9 (delta 0), reused 0 (delta 0), pack-reused 6
Receiving objects: 100% (9/9), 16.00 KiB | 2.67 MiB/s, done.

C:\gittest>git branch
fatal: not a git repository (or any of the parent directories): .git

C:\gittest>cd StudyProjects

C:\gittest\StudyProjects>git branch
* master

C:\gittest\StudyProjects>git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master

C:\gittest\StudyProjects>git branch -r
origin/HEAD -> origin/master
origin/master

C:\gittest\StudyProjects>git branch devproj

C:\gittest\StudyProjects>git branch
devproj
* master

C:\gittest\StudyProjects>git checkout devproj


Switched to branch 'devproj'

C:\gittest\StudyProjects>git status
On branch devproj
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Untitled4.ipynb

no changes added to commit (use "git add" and/or "git commit -a")

C:\gittest\StudyProjects>git add Untitled4.ipynb

C:\gittest\StudyProjects>git status
On branch devproj
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: Untitled4.ipynb

C:\gittest\StudyProjects>git commit -m 'dev update'


error: pathspec 'update'' did not match any file(s) known to git

C:\gittest\StudyProjects>git commit -m "devupdate"


Author identity unknown

*** Please tell me who you are.

Run

git config --global user.email "[email protected]"


git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'Argha@LAPTOP-1CDMUN0L.(none)')

C:\gittest\StudyProjects>git init
Reinitialized existing Git repository in C:/gittest/StudyProjects/.git/

C:\gittest\StudyProjects>git config user.name "argha raha"

C:\gittest\StudyProjects>git config user.email "[email protected]"

C:\gittest\StudyProjects>git commit -m "devupdate"


[devproj 10cacf3] devupdate
1 file changed, 2 insertions(+)

C:\gittest\StudyProjects>git push origin devproj


fatal: helper error (-1): User cancelled dialog.
Username for 'https://github.com':
C:\gittest\StudyProjects>

C:\gittest\StudyProjects>git push origin devproj


Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 293 bytes | 293.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote:
remote: Create a pull request for 'devproj' on GitHub by visiting:
remote: https://github.com/argharaha/StudyProjects/pull/new/devproj
remote:
To https://github.com/argharaha/StudyProjects.git
* [new branch] devproj -> devproj

C:\gittest\StudyProjects>git branch
* devproj
master

C:\gittest\StudyProjects>git branch -a
* devproj
master
remotes/origin/HEAD -> origin/master
remotes/origin/devproj
remotes/origin/master

C:\gittest\StudyProjects>git branch
* devproj
master

C:\gittest\StudyProjects>git branch -a
* devproj
master
remotes/origin/HEAD -> origin/master
remotes/origin/devproj
remotes/origin/master

C:\gittest\StudyProjects>git fetch --all


remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
Unpacking objects: 100% (3/3), 666 bytes | 95.00 KiB/s, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
From https://github.com/argharaha/StudyProjects
* [new branch] testproj -> origin/testproj

C:\gittest\StudyProjects>git branch -a
* devproj
master
remotes/origin/HEAD -> origin/master
remotes/origin/devproj
remotes/origin/master
remotes/origin/testproj

C:\gittest\StudyProjects>git checkout testproj


Switched to a new branch 'testproj'
branch 'testproj' set up to track 'origin/testproj'.

C:\gittest\StudyProjects>git branch
devproj
master
* testproj

C:\gittest\StudyProjects>git checkout devproj


Switched to branch 'devproj'

C:\gittest\StudyProjects>git checkout testproj


Switched to branch 'testproj'
Your branch is up to date with 'origin/testproj'.

C:\gittest\StudyProjects>git add testaddfile.txt

C:\gittest\StudyProjects>git status
On branch testproj
Your branch is up to date with 'origin/testproj'.

Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: testaddfile.txt

C:\gittest\StudyProjects>git commit -m "new add file test"


[testproj 5caaa8d] new add file test
1 file changed, 1 insertion(+)
create mode 100644 testaddfile.txt

C:\gittest\StudyProjects>git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 287 bytes | 287.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/argharaha/StudyProjects.git
85834a7..5caaa8d testproj -> testproj
C:\gittest\StudyProjects>

You might also like