Github and Git
Github and Git
Github
- Website that allows developers to store and manage their code using Git.
- Website :- https://github.com
- It used to store the code on website , manage it (means add , delete or modify
the code
- It is used to reflect the changes made on system on uploaded code too.
- The code is uploaded on github in a container (means folder) named as
Repository .
- For finalizing the changes there is option in GITHUB called as commit
- README.md file is used to give description about the code .
- It also have some special command like html(basic html should be sufficient to make changes in it).
- md means mark down .
__________________________________________________________________________________
Setting up Git
clear is used.
After the setup is done . we have configure the git means by which account we
are making changes on Github too
- Syntax –
git clone <some links>
In github there is green option of text code click on it and copy the https link and
paste it in vscode terminal / git terminal in above format
REMOTE LOCAL MACHINE
[GITHUB] [LAPTOP]
COPYING
ls(List Files) –
ls –a –
mkdir –
2) status –
This command is used to check the status the which is one git repository and local
machine.
types of status
1- untracked
new files that doesn’t tracked yet.
2- modified
Changed.
3- staged
file is ready to be committed
4- unmodified
unchanged.
-when we make changes or add files in the repository it will set to status modified
or untracked respectively.
-We have to add this files on add . After adding the status of file changes from
untracked \ modified to staged(Ready to commit)
-After adding we commit the changes and status will turn into unchanged
4) commit –
It is the record of change.
Syntax –
git commit –m “some message”
6) init command
init – used to create a new repo on git
Syntax-
git init
git remote add origin <link>
git remote –v (to verify remote)
git branch (to check branch)
git branch –M main (to rename branch)
git push origin main / git push -u origin main (It means all the files
will be added to this branch and next time when we add we use only git
push command.)
Example –
Suppose we create a new directory on local file . We first make it
git repo using git init command then it will be initialized to git repo.
Now we will make a repo on github and will add the remote repo on local
machine by git remote add origin <link> command . Now we can
check the repo by git remote –v command . We can check it branch by
git branch command . we can change the current branch name we use
git branch –M branchname .After this we can modify the file and will
push by git push origin main / git push –u origin main command.
(-u means set upstream . from now all changes will be done in this
branch).
WorkFlow –
local git
WAY 1
WAY 2
used to fetch and download content from a remote repo and immediately
update the local repo to match the content.
Resolving Merge Conflicts
- when we do changes in both sames files or same lines in different
branches then get confused which changes should kept .In this case
we use this event.
- An event that takes place when git is unable to automatically resolve
differences in code.
Undoing changes