0% found this document useful (0 votes)
61 views

Git and Github Notes

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Git and Github Notes

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 110

Git and Github Notes

This is central version system system.But git is distributive version system.in distributive version
system individual tracking of system is possible but in git individual tracking of system is not possible.

GIT VS GITHUB
GITHUB INSTALLATION AND CREATION OF ACCOUNT

GIT TRACKS THE PROGRAM IN LOCAL SYSTEM BUT GITHUB IS CONNECTING THE PROGRAM IN
INTERNET WHICH MAKES THE DEVLOPERS LIFE EASY
Github->signup->email->password->username->solve the puzzle 😊->enter verification code

GIT CONFIGURATION->USERNAME AND EMAIL


Generally the company project is cloned into local repository so there is no need to do git init for that
project which we cloned into local system and to work on it.
Create a project(folder)

In location taksar above enter cmd to open terminal

Enter git status

Replies not a git repository

Now enter git init

Now git starts to track the repository.a hidden file is created to see it you need to see hiddent items

To see the hidden git file enter view and click hidden items

You can see the hidden.


Now load(open) the folder in vs editor.cmd can be used in

Here index .html is an untracked file which means it is not tracked by git

Git add command need to be used to track the


We created two files

And we have done git status

Now we git respoded not added

And we have added certain commands in index.html page(simply modified index.html file)
Git add . is used to add all instead of specifying name for each file
How to upload github projects

Till now we have done local repository of git but now we are going to do remote repository which is

The projects which we create till now are available in local repository but to integrate in a team the
repository should be in internet

Create repository->private->quiz->descirtion give something->add a readme file()->add a git ignore -


>create repositor

y
Push an existing repository is to be used as we need to push our existing repository in github

Now again in our local repository we created a new git tracking repository now we need to push
these in GITHUB.
An authentication comes when we are pushing local repository to remote repository

-u is telling orgin master is common.


Git sttaus and git add use karo

Now git commit -m “test file added”

Stging area level is must


No origin no master this is because of -u used before which automatically tells which github account
to be connected

This worked because of upstream command


Enter q to exit from column
We need to push it into remote repository.
Settings->collaborators->add people->enter github username or email

Changed
This is thorugh collaborators

Let s go to access tokens


A prompt is opened and it will ask

Shown a token option

Here through this token option and this will be given by repo owner

Then it will be done 😊


😐
CHANGES MADE IN REMOTE REPOSITORY FETCHING THEM IN THE CURRENT ONE WHICH WE HAVE
IS CALLED PULL REQUEST AND TO PUSH THE CHANGES WE MADE IS CALLED PUSH.
She’s adding a file directly in the github by not changing in local system.
I have 2 commits in github and one commit in git

Here in local we only have one 😊


We are bringing the change in our local repository frm remote repository 😊

See order.html is added here

We have pulled the change and now we are pushing the changes we are going to make into github
Here 3 commits are there in local but in remote repository only 2 are there
Changes in remote to local->pull

Changes in local to remote->push


Change is to be added nad then commited 😊
What is gitignore

Obvioslu when git is initialised we don’t want some files to be tracked by git so using git git ignore we
ignore those files
Difference between /node_module(root directory) and node_module/(any path)

Seeing the working of git ignore file


Now I want to ignore test.txt and I want to ignore it.so I create a file called .gitignore

So I stopped tracking git ignore 😊

We are creating config.js and we want to ignore this file


This wants to be pushed

We need to mention this name config.js


It is not tracking
Here I need to ignore .txt file how

*.txt is the solution 😊 for regular expression kinda things


So here temp files we didn’t get 😊

Subfolder creating temp shes creating and then you need to keep temp/ to ignore it
Here we go to a github project and see its read me and see what is meant by readme
Read me is nothing but it’s a description of project kind of thing it’s a file with extension with md 😊
Everytime we commit an id is generated here food app an index.html file is generated and header tag
is added
This is commited in git nd then I changed it

This is footer is added and style .css is linked to this css file
We need to see the difference between two commits

Git log is the command used


To see the commit in one line
Here we hanged to that commit
Now we got the latest version

So we came back to the latest version by this command.


Head~1 ante head previous commit (head-1 ra ayya ani )
Whats happening the css file is getting removed.a new commit is getting added and then the commit
which is added is removing the css part commit
See the tree message

Click commit there click ok if its not working then kill process

Here this cs sig getting dead


No text message is asked just removes it
GIT branches

What happens is live users keep using the application and we shouldn’t disturb the live code so we

need to make a branch and work on it and then merge once the testing is over 😊

Using git we can create multiple branches.


This merges with the branch in which we are in 😊

To delete after merging of the branch 😊


Merge conflicts in Git
Demonstration 😊
Creating a branch 😊
Now I have changed the contents of this file and commited if I merge nothing happens at this stage

but if I change master branch and then try to merge then I get some conflicts 😊 😊

Why ☹

Because after creating branch and changing content then trying to merge nothng does happen 😊
If after deleting test 1 and creating new file called as test 2 and then commition in main branch then I

am trying to merge dev branch with main branch then I get a error 😐
GIT PULL
Git merging in local repo is different from git merging in remote repository

Used heavily in open source projects


Added signup.html in dev branch and I need to merge it in main branch
See pull requests
We can comment and close pull request to deny or confirm merge to accept
Here the branches are merged .

This repo clone create new branch change it and then lets create a pull request
To get remote repo branches click -a
Clone and we will create a new branch
Creating a new file called products .html
GIT FORK 😊
100s cant get token
Added signup

You might also like