PC@DESKTOP-HQJ0IQR MINGW64 ~
$ mkdir myrepo
PC@DESKTOP-HQJ0IQR MINGW64 ~
$ cd myrepo
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo
$ git init
Initialized empty Git repository in C:/Users/PC/myrepo/.git/
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ ls -la .git
total 11
drwxr-xr-x 1 PC 197121 0 Oct 9 15:20 ./
drwxr-xr-x 1 PC 197121 0 Oct 9 15:20 ../
-rw-r--r-- 1 PC 197121 23 Oct 9 15:20 HEAD
-rw-r--r-- 1 PC 197121 130 Oct 9 15:20 config
-rw-r--r-- 1 PC 197121 73 Oct 9 15:20 description
drwxr-xr-x 1 PC 197121 0 Oct 9 15:20 hooks/
drwxr-xr-x 1 PC 197121 0 Oct 9 15:20 info/
drwxr-xr-x 1 PC 197121 0 Oct 9 15:20 objects/
drwxr-xr-x 1 PC 197121 0 Oct 9 15:20 refs/
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ touch newfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git add newfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git config --global user.email "
[email protected]"
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git config --global user.name "ayoub"
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git commit -m "added newfile"
[master (root-commit) 0d51cad] added newfile
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 newfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git branch my1stbranch
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git branch
* master
my1stbranch
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git checkout my1stbranch
Switched to branch 'my1stbranch'
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1stbranch)
$ git branch
master
* my1stbranch
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1stbranch)
$ git checkout -b my1srbranch
Switched to a new branch 'my1srbranch'
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ echo 'Here is some text in my newfile.' >> newfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ cat newfile
Here is some text in my newfile.
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ touch readme.md
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git add readme.md
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git status
On branch my1srbranch
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: readme.md
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: newfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git add *
warning: in the working copy of 'newfile', LF will be replaced by CRLF the next
time Git touches it
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git status
On branch my1srbranch
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: newfile
new file: readme.md
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git commit -m "added readme.md modified newfile"
[my1srbranch 1d11e71] added readme.md modified newfile
2 files changed, 1 insertion(+)
create mode 100644 readme.md
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git log
commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29 (HEAD -> my1srbranch)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:40:19 2023 +0100
added readme.md modified newfile
commit 0d51cad6f6aa29bd4115cb9fd9a82cf82bd59912 (my1stbranch, master)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:34:08 2023 +0100
added newfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git revert HEAD --no-edit
[my1srbranch 0937c00] Revert "added readme.md modified newfile"
Date: Mon Oct 9 15:43:08 2023 +0100
2 files changed, 1 deletion(-)
delete mode 100644 readme.md
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ touch goodfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git add goodfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git commit -m "added goodfile"
[my1srbranch f23a784] added goodfile
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 goodfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git log
commit f23a784957f1704cb479c6a39f070cb7fe5dc89e (HEAD -> my1srbranch)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:44:09 2023 +0100
added goodfile
commit 0937c00c7b41c6c3c48205f50cafe832ad42a77f
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:43:08 2023 +0100
Revert "added readme.md modified newfile"
This reverts commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29.
commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:40:19 2023 +0100
added readme.md modified newfile
commit 0d51cad6f6aa29bd4115cb9fd9a82cf82bd59912 (my1stbranch, master)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:34:08 2023 +0100
added newfile
(END)
commit f23a784957f1704cb479c6a39f070cb7fe5dc89e (HEAD -> my1srbranch)
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:44:09 2023 +0100
added goodfile
commit 0937c00c7b41c6c3c48205f50cafe832ad42a77f
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:43:08 2023 +0100
Revert "added readme.md modified newfile"
This reverts commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29.
commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:40:19 2023 +0100
added readme.md modified newfile
commit 0d51cad6f6aa29bd4115cb9fd9a82cf82bd59912 (my1stbranch, master)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:34:08 2023 +0100
ESCOD
commit f23a784957f1704cb479c6a39f070cb7fe5dc89e (HEAD -> my1srbranch)
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:44:09 2023 +0100
added goodfile
commit 0937c00c7b41c6c3c48205f50cafe832ad42a77f
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:43:08 2023 +0100
Revert "added readme.md modified newfile"
This reverts commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29.
commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:40:19 2023 +0100
added readme.md modified newfile
commit 0d51cad6f6aa29bd4115cb9fd9a82cf82bd59912 (my1stbranch, master)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:34:08 2023 +0100
ESCOC
5dc89e (HEAD -> my1srbranch)
42a77f
ile"
eee2ec4a3491fe3c0aaae29.
aaae29
d59912 (my1stbranch, master)
ESCOD
commit f23a784957f1704cb479c6a39f070cb7fe5dc89e (HEAD -> my1srbranch)
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:44:09 2023 +0100
added goodfile
commit 0937c00c7b41c6c3c48205f50cafe832ad42a77f
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:43:08 2023 +0100
Revert "added readme.md modified newfile"
This reverts commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29.
commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:40:19 2023 +0100
added readme.md modified newfile
commit 0d51cad6f6aa29bd4115cb9fd9a82cf82bd59912 (my1stbranch, master)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:34:08 2023 +0100
ESCOC
5dc89e (HEAD -> my1srbranch)
42a77f
ile"
eee2ec4a3491fe3c0aaae29.
aaae29
d59912 (my1stbranch, master)
ESCOD
commit f23a784957f1704cb479c6a39f070cb7fe5dc89e (HEAD -> my1srbranch)
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:44:09 2023 +0100
added goodfile
commit 0937c00c7b41c6c3c48205f50cafe832ad42a77f
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:43:08 2023 +0100
Revert "added readme.md modified newfile"
This reverts commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29.
commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:40:19 2023 +0100
added readme.md modified newfile
commit 0d51cad6f6aa29bd4115cb9fd9a82cf82bd59912 (my1stbranch, master)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:34:08 2023 +0100
ESCOD
commit f23a784957f1704cb479c6a39f070cb7fe5dc89e (HEAD -> my1srbranch)
commit f23a784957f1704cb479c6a39f070cb7fe5dc89e (HEAD -> my1srbranch)
commit f23a784957f1704cb479c6a39f070cb7fe5dc89e (HEAD -> my1srbranch)
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:44:09 2023 +0100
added goodfile
commit 0937c00c7b41c6c3c48205f50cafe832ad42a77f
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:43:08 2023 +0100
Revert "added readme.md modified newfile"
This reverts commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29.
commit 1d11e71ed07bfbeeeeee2ec4a3491fe3c0aaae29
Author: ayoub <[email protected]>
Date: Mon Oct 9 15:40:19 2023 +0100
added readme.md modified newfile
commit 0d51cad6f6aa29bd4115cb9fd9a82cf82bd59912 (my1stbranch, master)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:34:08 2023 +0100
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (my1srbranch)
$ git checkout master
Switched to branch 'master'
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git merge my1stbranch
Already up to date.
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git log
commit 0d51cad6f6aa29bd4115cb9fd9a82cf82bd59912 (HEAD -> master, my1stbranch)
Author: ayoub <
[email protected]>
Date: Mon Oct 9 15:34:08 2023 +0100
added newfile
PC@DESKTOP-HQJ0IQR MINGW64 ~/myrepo (master)
$ git branch -d my1stbranch
Deleted branch my1stbranch (was 0d51cad).
By now you should be familiar with the difference between fork and clone. So let’s
summarize when you should clone vs. fork. Typically if you have access to a project
repo e.g. as part of a team developing a codebase collaboratively, you can clone
the repo and synchronize changes from your local copy of the repo using pull and
push.
If however there is a public project that you want to contribute to but do not have
write access to, or use a public project as a starting point for your own project,
you can fork the project. Then work with the forked codebase by cloning it to your
machine and collaborating with your development team working on the fork using the
pull-push synchronization with your fork of the project. But if you want to
contribute your changes back to the upstream project (the original project that you
forked from), you can submit your changes using a pull request.
In this reading you learned that:
A clone is essentially your copy of a project that you can make changes to.
You can create local copy of a project by using the git clone command.
The project from which you clone from is called the origin.
You can pull updates from the origin and push your changes back to it.
A fork is an separate copy of a project that you can make changes to independently
of the original project
The project that you fork from is referred to as the upstream project
You can suggest changes back to the upstream project by submitting a Pull Request
(PR)
In this reading you learned that:
A clone is essentially your copy of a project that you can make changes to.
You can create local copy of a project by using the git clone command.
The project from which you clone from is called the origin.
You can pull updates from the origin and push your changes back to it.
A fork is an separate copy of a project that you can make changes to independently
of the original project
The project that you fork from is referred to as the upstream project
You can suggest changes back to the upstream project by submitting a Pull Request
(PR)
PC@DESKTOP-HQJ0IQR MINGW64 ~
$ export ORIGIN=https://github.com/AyoubUFC70/gkpbt-css-circle.git
PC@DESKTOP-HQJ0IQR MINGW64 ~
$ git clone $ORIGIN
Cloning into 'gkpbt-css-circle'...
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 19 (delta 4), reused 4 (delta 4), pack-reused 11
Receiving objects: 100% (19/19), 8.04 KiB | 2.01 MiB/s, done.
Resolving deltas: 100% (4/4), done.
PC@DESKTOP-HQJ0IQR MINGW64 ~
$ cd gkpbt-css-circle
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git checkout -b feature-circle-500
Switched to a new branch 'feature-circle-500'
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git status
On branch feature-circle-500
nothing to commit, working tree clean
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git status
On branch feature-circle-500
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: style.css
no changes added to commit (use "git add" and/or "git commit -a")
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git diff ./style.css
diff --git a/style.css b/style.css
index b1a4e3b..e5b7463 100644
--- a/style.css
+++ b/style.css
@@ -3,6 +3,6 @@
}
.circle{
border-radius:50%;
- width:300px;
- height:300px;
+ width:500px;
+ height:500px;
}
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git add .
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git status
On branch feature-circle-500
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: style.css
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git config --global user.email "
[email protected]"
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git config --global user.name "ayoub"
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git commit -m "Changing the height and the width of the circle"
[feature-circle-500 66f30f8] Changing the height and the width of the circle
1 file changed, 2 insertions(+), 2 deletions(-)
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git status
On branch feature-circle-500
nothing to commit, working tree clean
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git branch
* feature-circle-500
main
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-circle-500)
$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git branch
feature-circle-500
* main
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git merge feature-circle-500
Updating 729ceb2..66f30f8
Fast-forward
style.css | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git log --oneline
66f30f8 (HEAD -> main, feature-circle-500) Changing the height and the width of the
circle
729ceb2 (origin/main, origin/HEAD) Automatically close PRs
0169944 Update README.md
8f09fd1 Create style.css
2d31fb1 Create circle.html
11bec50 Initial commit
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git checkout main
Already on 'main'
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git branch -d feature-circle-500
Deleted branch feature-circle-500 (was 66f30f8).
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git branch
* main
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git push origin main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 349 bytes | 349.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/AyoubUFC70/gkpbt-css-circle.git
729ceb2..66f30f8 main -> main
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git branch feature-add-color
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git branch
feature-add-color
* main
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git checkout feature-add-color
Switched to branch 'feature-add-color'
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-add-color)
$ git branch
* feature-add-color
main
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-add-color)
$ git add -A
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-add-color)
$ git commit -sm "adding red color feature"
[feature-add-color b74fab9] adding red color feature
1 file changed, 3 insertions(+)
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (feature-add-color)
$ git checkout main && git merge feature-add-color
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
Updating 66f30f8..b74fab9
Fast-forward
style.css | 3 +++
1 file changed, 3 insertions(+)
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git branch -d feature-add-color
Deleted branch feature-add-color (was b74fab9).
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git branch
* main
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git push origin main
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/AyoubUFC70/gkpbt-css-
circle.git/'
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git push origin main
fatal: User canceled device code authentication
error: unable to read askpass response from 'C:/Program Files/Git/mingw64/bin/git-
askpass.exe'
Password for 'https://
[email protected]':
PC@DESKTOP-HQJ0IQR MINGW64 ~/gkpbt-css-circle (main)
$ git push origin main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 331 bytes | 331.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.
To https://github.com/AyoubUFC70/gkpbt-css-circle.git
66f30f8..b74fab9 main -> main
Branches are used to isolate changes to code. When the changes are complete, they
can be merged back into the main branch.
Repositories can be cloned to make it possible to work locally, then sync changes
back to the original.
Repositories can be forked to be used as a base for a new project, or so that the
developer can work independently.
A Pull Request (PR) can be submitted to have your changes reviewed and merged.
Large projects include people working in different roles:
Developer – creates code
Integrator – manages changes made by developers
Repository Administrator – configures and maintains access to the repository