Git And GitHub
Git AnD GitHub
* Git:-
A Version Control System is a tool for tracking code changes. Git is a version control system.
1. Free & Open Source
2. Fast & Scalable
3. Track the history
4. Collaborate
* Github:-
The website that allows developers to store and manage their code using Git.
1. Folder(Repository)
2. Create a new repository: firstproject
3. Make our first commit
* Setting Up Git:-(git-scm.com link)
1. Visual Studio Code
2. Windows(Git Bash)
3. Mac(Terminal)
* Configuring Git:-
1. git config-- global user. name "My name"
2. git config-- global user.email "My email"
3. git config-- list
* Clone & Status:-
1. Clone- Cloning the repository on our local machine
git clone <- some lin ->
2. Status- Displays the state of the code
git status
** Local means [Laptop/PC] and Remote means[Github]
** CD means Change Directory
** LS means List File
** ls -a showing all hidden files
** untracked:- new files that git doesn't yet track
** modified :- changed
** staged:- file is ready to be committed
** unmodified :- unchange
* Add and Commit:-
1. Add:- adds new or changed files in your working directory to the Git staging area.
git add <- file name ->
git add. means all files are added
2. Commit:- it is the record of change
git commit -m "some message you're according "
* Push Command:- upload local repo content to remote repo
git pull origin main
git push origin main
git push origin main-- force
* Init Command:- used to create a new git repo
git init
git remote add origin <- link ->
git remote -v (to verify remote)
git branch (to check the branch)
git branch -M main (to remote branch)
git push origin main
** cd .. This command is used to go back one step (Folder)
** mkdir "filename". This command helps me create a new file.
** Get-ChildItem -Force
** ls -Force
## Work Flow :- Github repo -> clone -> changes -> add -> commit -> push
* Branch Command:-
git branch (to check the branch)
git branch -M main (to rename the branch)
git checkout <- branch name -> (to negative)
git checkout -b <- new branch name -> ( to create new branch)
git branch -d <- branch name -> (to delete branch)
example:-
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git branch
* main
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git checkout -b feature1
Switched to a new branch 'feature1'
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git branch
* feature1
main
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git checkout main
Switched to branch 'main'
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git branch
feature1
* main
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git checkout feature1
Switched to branch 'feature1'
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git branch
* feature1
main
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git checkout -b feature2
Switched to a new branch 'feature2'
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git branch
feature1
* feature2
main
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git checkout main
Switched to branch 'main'
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git branch
feature1
feature2
* main
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git branch -d feature2
Deleted branch feature2 (was 18dcab8).
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo> git branch
feature1
* main
PS C:\Users\cracm\Desktop\Gitdemo\LocalRepo>
** Merging Code:-
1. Way 1:-
git diff <- branch name -> (to compare commits, branch, files & more)
git merge <- branch name -> (to merge 2 branches)
2. Way 2:-
Create a PR (PR is a Pull Request)
** What is a Pull Request:- It lets you tell others about changes you've pushed to a branch in a repository on GitHub
* Pull Command:- used to fetch and download content from a remote repo and immediately update the local repo to match the content.
git pull origin main
* Resolving Merge Conflicts:- An event that takes place when Git is unable to automatically resolve differences in code between two commits.
* Undoing Changes:- Case 1: staged changes
git reset <- file name ->
git reset
Case 2: Commited changes(for one commits )
git reset HEAD~1
Case 3: Commited changes (for many commits)
git reset <- commit hash ->
git reset --hard <-commit hash ->
*Fork: A Fork is a new repository that shares code and visibility settings with the original "upstream" repository. Fork is a rough copy.
Example:-
cracm@cracmindboyrk MINGW64 ~
$ cd d:
cracm@cracmindboyrk MINGW64 /d
$ ls
'$RECYCLE.BIN'/ FinalProject.rar ShakumbariWeigment-Running/ api.rar httrack/
BCA/ GreenPlyapp/ ShakumbariWeigment-Running.rar backup/ petalsweb/
BSC2324RUNING-1200V/ GreenPlyapp.rar 'System Volume Information'/ bmacinfotech-cmrtolerance.android-2f23f617e0e5/ resumbe.pdf
BhagesworSurvey/ GreenPlylatestcode/ TestProject/ bmacinfotech-cracsurveyapp.android-10.05.24/ setup/
CMR/ GreenPlylatestcode.rar 'Video link'/ bmacinfotech-cracsurveyapp.android-10.05.24.rar shakumbariapp/
CMRAPP-501-2023-07-19/ JAVA/ WINDOW_APPLICATION2023/ cane_indu/ survey/
'CaneManagement-RAJAPUR-19-OCT-2024 - loan'/ Resume/ WINDOW_APPLICATION2023.rar 'center Weighment Unloading'/
FinalProject/ 'Shakumbari Unloading'/ api/ cmrproject/
cracm@cracmindboyrk MINGW64 /d
$ cd BhagesworSurvey/
cracm@cracmindboyrk MINGW64 /d/BhagesworSurvey (main)
$ ls
README.md app/ build.gradle gradle/ gradle.properties gradlew* gradlew.bat local.properties settings.gradle
cracm@cracmindboyrk MINGW64 /d/BhagesworSurvey (main)
$ git add .
cracm@cracmindboyrk MINGW64 /d/BhagesworSurvey (main)
$ git commit -m "Cultivation App"
On branch main
nothing to commit, working tree clean
cracm@cracmindboyrk MINGW64 /d/BhagesworSurvey (main)
$ git remote add origin https://github.com/LearnWithRehan/Cane-Cultivation.git
error: remote origin already exists.
cracm@cracmindboyrk MINGW64 /d/BhagesworSurvey (main)
$ git branch -M main
cracm@cracmindboyrk MINGW64 /d/BhagesworSurvey (main)
$ git push -u origin main
Enumerating objects: 121, done.
Counting objects: 100% (121/121), done.
Delta compression using up to 8 threads
Compressing objects: 100% (105/105), done.
Writing objects: 100% (120/120), 2.98 MiB | 1.28 MiB/s, done.
Total 120 (delta 10), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (10/10), done.
To https://github.com/LearnWithRehan/Cane-Cultivation.git
b68c280..0801c1c main -> main
branch 'main' set up to track 'origin/main'.
cracm@cracmindboyrk MINGW64 /d/BhagesworSurvey (main)
$
Command:-
echo "# Vb.netWindowApplication" >> README.md git init git add README.md git commit -m "first commit" git branch -M main git remote add origin https://github.com/LearnWithRehan/Vb.netWindowApplication.git git push -u origin main
//happens because Git sees a mismatch between the folder owner and the current user
You already used the correct fix:
git config --global --add safe.directory D:/WINDOW_APPLICATION2023
Comments
Post a Comment