GIT AND GITHUB
What is Git ?
GIT AND GITHUB a is Free and open Source version control, system. Tool that help to track changes in code.
when we are working on project in groups
Version controll systems are used to track changes code in project
For example developes changes code in project
Version control system shows Whether he made changes in same file, or same code to track history etc
version control System track history,help to colaborate
Gib is fast and scalable, we can deal with bigger projects
What is Github ?
Website where we host repositories online
→README.md md means markdown we can write why project is made, what features does project have etc.
Commit means it shows the changes. it shows the changes & Git has two steps to change
first Change are added and then commit those changes. Commit means saving in memory
add —-> commit
To understand take this example
If you you will write a letter this is add After keeping & sticking stamp we can finally that letter. Here sticking stamp is commit.
When you go to initial commit the area which is in green color will show the new changes. Red color will show what we deleted.
We can also make changes in README by cheking Pencil symbol (Edit option) Every small change should be comitted.
→After making change you can see will be changed to what that initial commit Update README.md. (its our wish we can change the name (update…))
Configuring Git
git config –global user name “My Name
git config –global uses.email abc@giraihtorn
global means where git it used in our system we will have above
uses name and email git config –global user name Git with uscode “abcdefegh”
git config –global user email abc@gmail.com
Git with VScode
Open VScode click create folder you can access git in access vs code through at bottom feft and it has terminal. window in terminal corner in vs code you can
Basic commands
clone repository on our local machine.
clone – Cloning a repository on your local machine. To Bring repo from github to our local system that we will Clone that Repo clone means ,(in github) it has its copy download that repo to bring into our system
git clone <—- some links —->
To get link go to <code> button in green color click that button you will get HTTPS SSTl GITHUB uses HTTPS link
ls -a to see hidden files
In VScode to make changes in README.md. If you want # Teacher , # space teacher will make bold mak. whenever you make code the changes or github files in VS Code the color of files will be changed.
Status:
Status command displays the state of the code when we made changes in the code status of the code will be changed.
Any new file will be in untracked state when tou add the file it will come to unmodified state when we makes changes in the files use git status. Type git status in terminal.
Add and Commit Commands:
Add adds a new or changed files in your working directory to the git staging area. git add—<file name—>.
if we add the modified files, status of files is changed to staged and we commit it comes to unmodified state git add. to add all commit it is the record of change
git commit -m “some message”
writing message is compulsory we need to write some meaningful message
Create anew file in git folder in vs code
example:index.html
add the file git add index.html commit the changes, git commit -m “add new files” It will show the 1 file is changed.
Push command: upload local repo content to remote repo. If we want see the changes that we made in our computer to eb reflected in github we use push command
if you got this error when you tried to use git status in vs code. Error is fatal: not a git repository (or any of hte [arent directory): .git
TO resolve this error used at delta-demo/ then you use git status now the error is resolved if you are working with multiple accounts older credential is windows.
Intit Command: init – used to create a new git repo git init click +v to select bash terminal. Create new folder project 2 directory if you are not in project then cd project 2/ you will go to project 2 directory. Following are steps to push projets into githhub.
Go to github account create a new repository named project 2 do not any readme.md
git remote ass origin <—link—>
link is when you click preoject repository that is created before github will give some steps in quick setup you will have link HTTPS copy that and paste it in link
to verify we can use git remote -v git branch it is remote to check branch
git branch -M main to rename branch, branch is renamed to main
git push origin main
process
git remote add origin “link that you copied”
git add .
git commit -m “Add number”
git push origin main
if you write git push -u origin main -u means upstream once another time git push is enough
If you to commit and add at a time. git commit -am ” added dot”