0% found this document useful (0 votes)
3 views4 pages

git commands

The document provides a comprehensive overview of basic Git commands and workflows, including initializing a repository, committing changes, creating and merging branches, and managing files. It details how to delete files and branches, undo changes, and handle unstaged changes. The document serves as a practical guide for users to navigate Git's version control system effectively.

Uploaded by

kibirighenry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

git commands

The document provides a comprehensive overview of basic Git commands and workflows, including initializing a repository, committing changes, creating and merging branches, and managing files. It details how to delete files and branches, undo changes, and handle unstaged changes. The document serves as a practical guide for users to navigate Git's version control system effectively.

Uploaded by

kibirighenry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

git basics

Working directory(code version)

tracking part(snap shot repository hidden area)= commit code snapshot(message u and
other developer are aware) and branch (where commits are stored) and stored in the
main/master

feature

git init
git add test.text
git commit -m "test.txt added"
git config --global user.name
git commit -m "added test.txt file"

PS C:\Users\kibir\Desktop\git-basics new> git status


On branch master
nothing to commit, working tree clean means snapshot saved
PS C:\Users\kibir\Desktop\git-basics new>

PS C:\Users\kibir\Desktop\git-basics new> git log


commit 0a94fe9325aaccec8faf0d05b8e825c41ab0c0d6 (HEAD -> master)
Author: kibirige henry <kibirighenry@gmail.com>
Date: Tue Jun 24 20:55:57 2025 +0300

added test.txt file

master is the default working branch is the one holding running code if want to add
new features u create new branch and add the new changes then to the master

PS C:\Users\kibir\Desktop\git-basics new> git branch -m main (for renaming the


current working branch)
PS C:\Users\kibir\Desktop\git-basics new> git branch
* main

PS C:\Users\kibir\Desktop\git-basics new> git checkout -b feature (for creating


future branch and switching between branches)
Switched to a new branch 'feature'
PS C:\Users\kibir\Desktop\git-basics new> git branch
* feature
main
PS C:\Users\kibir\Desktop\git-basics new>

================== NOW MERGING BRANCHES =========================

PS C:\Users\kibir\Desktop\git-basics new> git merge feature


Updating 934ccbf..18bb979
Fast-forward
new-feature/feature.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 new-feature/feature.txt
PS C:\Users\kibir\Desktop\git-basics new>

=============== NOW FEATURE AVAILABLE IN BOTH BRANCHES ==============

commit 18bb979e2e2b584e16b644aba6c1b20943d081e3 (HEAD -> main, feature)


Author: kibirige henry <kibirighenry@gmail.com>
Date: Tue Jun 24 21:25:01 2025 +0300

added new feature

commit 934ccbf538de41cf3cc5800e29c2af51dc2f2f92
Author: kibirige henry <kibirighenry@gmail.com>
Date: Tue Jun 24 21:14:52 2025 +0300

changed test.txt and added seccond-commit.txt

commit 0a94fe9325aaccec8faf0d05b8e825c41ab0c0d6
Author: kibirige henry <kibirighenry@gmail.com>
Date: Tue Jun 24 20:55:57 2025 +0300

PS C:\Users\kibir\Desktop\git-basics new>

================ deleting branches ==================

to dele a file first go in the that folder where the file is located

PS C:\Users\kibir\Desktop\git-basics new> cd new-feature


PS C:\Users\kibir\Desktop\git-basics new\new-feature> cd deleting-data
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git rm
file3.txt
rm 'new-feature/deleting-data/file3.txt'
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git rm
file1.txt
rm 'new-feature/deleting-data/file1.txt'
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git status
On branch delete
Changes to be committed:

===================== DELETING ACCESS TOKEN =========================


git credential reject
protocol=https
host=github.com

incase in cache
git credential-cache exit

===================== NEW bringing offline repository to offline


==========================

PS C:\Users\kibir\Desktop\github> git clone https://github.com/kibirigehenry/web-


dev-github.git .
Cloning into '.'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (8/8), done.
Receiving objects: 100% (16/16), done.
remote: Total 16 (delta 5), reused 16 (delta 5), pack-reused 0 (from 0
Resolving deltas: 100% (5/5), done.
PS C:\Users\kibir\Desktop\github>

(use "git restore --staged <file>..." to unstage)


deleted: file1.txt
deleted: file3.txt

===================== undoing delete of files and bring current files working area
===================

PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git reset --


hard HEAD~1
HEAD is now at ff268aa added file3.txt
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data>

================ DELETING BRANCH COZ WE NOLONGER NEED IT ========================

PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git branch -D


feature
Deleted branch feature (was 6baa52c).
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data>

==================== how to get rid of unstaged changes ========================

PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git status


On branch delete
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: file2.txt

no changes added to commit (use "git add" and/or "git commit -a")
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git checkout --
.
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data>

========================== FOR REMOVING STAGED CHANGES IN THE FILE


====================

PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git reset


file2.txt
Unstaged changes after reset:
M new-feature/deleting-data/file2.txt
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git status
On branch delete
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: file2.txt
no changes added to commit (use "git add" and/or "git commit -a")

==== OR =====

no changes added to commit (use "git add" and/or "git commit -a")
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data> git checkout --
file2.txt
PS C:\Users\kibir\Desktop\git-basics new\new-feature\deleting-data>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy