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

Git and GitHub: Version Control Guide

Git is a version control system created by Linus Torvalds in 2005, primarily used for tracking changes in code and facilitating collaboration. GitHub is a platform for storing and managing code using Git, allowing users to create repositories and manage branches for different features or experiments. Key commands include 'git commit' for recording changes, 'git push' for uploading to GitHub, and 'git merge' for combining branches.
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 views5 pages

Git and GitHub: Version Control Guide

Git is a version control system created by Linus Torvalds in 2005, primarily used for tracking changes in code and facilitating collaboration. GitHub is a platform for storing and managing code using Git, allowing users to create repositories and manage branches for different features or experiments. Key commands include 'git commit' for recording changes, 'git push' for uploading to GitHub, and 'git merge' for combining branches.
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

About Git and github related~~

(About git)~
*Git is a version control system. Version control system is a tool that helps
to track changes in code. We mainly use to
track the history and by the help of it we can perform any operation on the
previous history. And also for collaboration
at a huge group. In conclusion we can say thast git is for tracking the
history and for collaboration.
This git system was created by Linus Torvalds in 2005.
*This git system is basically only for script-directory management and for
tracking purposes of them. It is not just only for
[Link] this reason only Git is known as (Version Control System).

(Git Commands)~
*<git init>- Does not connects the folder with GitHub naturally nut we can
also use it for our local system file management.
And it is used for activating git at that folder.
*<git log>- It could be used to see the file history. (only the file history)
*<git log --stat>- It could be used to see, exactly what file have been
changed.
*<git clone>- cloning a repository on the local server or remote server.
(local server)- Means our own enviroment- say our own
machine.
(remote server)- Means a remote server that is at online
places like a GitHub.
*<git status>- It is used for seeking the status of the files.
~~~ Generally there are 4 types of status of a file.
1. (untracked)- New files that git doesn't yet tracked.
2. (modified)- Changed file after modification.
3. (staged)- File is ready to be commited, after- <git
add>.
4. (unmodified)- Unchanged file.
*For tracking the untracked file we can use <git add "file-name">
*<git restore --staged "file name">- This command could be used to unstage
the staged file.
*<git add "file name">- Adds new or changed files in your working directory
to the git staging area.
~Here working directory is that direcrory which is linked with
the main GitHub repo.
*To stage up all the changes of multiple files then use <git add .>.
*<git commit -m "message">- It is a record of the change and also for sending
the modified content to the launcher i.e git.
And we also must give meaningful messages.
*<git push origin "branch-name">- This command is used for commanding the git
to launch our origin i.e changed file from the that
branch. In short we write this command as <git
push>.
*<git init>- This command is used for creating a new git repo either for
local host oe remote host like GitHub.
*<git remote -v>- This command could be used to veify at which remote you are
what is it.
If there is a result after pressing enter then it would
indicate that git is connected with a remote
server means git is enabled with your local system.
*<git log --oneline>- This command is used for printing all the commits of
that repo that is commited till the beginning of
that rep.
*<git diff>- This command is used for differentiating betwene the previous
changes and the latest changes of any file.
*<git diff --staged "file-name">- This command is used for comparing the
previous and the latest changes of any staged
file, before committing it.
*<git diff HEAD "file-name">- This command is used for comparng between the
(commands for undoing of the staged changes)-
*<git reset "file-name">- This command is used for restoring of the
staged file to unstaged file. This command could
also be written as <git restore "file-name">.
It is mainly used in the case of
mistakened staging of any file, then we use
this command for restoring the mistake if
the user is supposed to.
*<git reset HEAD~1>- This command is used beyond the above command. It
is mainly used in the case of restoration of the
commited changes. It is only for single commited,
means when we want to go back one commit back
at time.
*<git reset --hard "commit-hash">- This command is used for restoring
those changes which were commited and where the
user wants to undo the new changes at the
txt editor itself.

(Branches in GitHub)- In GitHub, branches are separate versions of a repository


that allow you to work on different features or
experiments
without affecting the main project. The default branch is usually
called main or master, and you can create new
branches from it to make changes or test ideas.
There in GitHub we can see at the left part inside of a
reposiotry, a list of branches. Different
different branches have different work flows and that is
the main feature of branches in GitHub. <main>
branch could have different work status compared to the
<master> branch.
Though we can create multiple brnahces but the commit serial
number would be fixed. It is also possible to
merge two branches by equilifying both the codes of main branch
and the seperate branch. There main branch is
considered to be the main workflow of any project and it also the
default branch in GitHub. But we can change
the default branch in a repo.
*There are two types of branches in GitHub- Feature vranch
and main branch.
*Here merging means to equalify the code of the feature
branch with the main branch, means both the
codes containing of same code.
(commands related to branches)-
<git branch "branch_name">- This command is used for
creating a new branch.
<git branch -d "branch_name">- This command is used for
delting a local branch.
<git branch -D "branch_name">- This commadn is used for
forcefully deleting any remote branch.
<git push origin --delete "branch_name">- This command is
used for deleting any remote branch.
<git branch>- This command is used for checking the current
branch the user is using.
<git branch -M "branch_name">- This command is used for
renaming any branch.
<git branch -a>- This command is used for listing all the
existing branches,i.e local and remote
branches both
<git branch -r>- This command is used for listing remote
branches only.
<git checkout "branch_name">- This command is used for
switching to another branch. It works on pointers.
<git switch "branch_name">- This command is also used for
switching to another branch. But this works on
variables.
<git checkout -b "branch_name">- This command is used for
creating new branch.
<git diff "branch-name">- This command is mainly used for
comparison purposes.
<git merge "branch-name">- This command is used for merging
any 2 branches. This is the first method of
merging any two branches.

*In Git, fetch means to download and merge means to combine. There {fecth ==
get changes and merge == apply changes}.

(conceptual)- The branches and merging are more prevelant for increasing the
efficiancy of the work of the project.
different contributors could do different work for the project
and all of them at final merges there
contribution with the main project. So because of this, the
workflow and the speed of the project also
increases and also the work quality increases.

(Pull)- It is used to fectch the content from the remote repo and immediately
merge the content with the local repo.

(Pull Requests- merging through it~ method2)- It is the second method of


merging of any two branches. In this method, we dont
use any special commands in terminal but
it is merging by granting permission,
to a senior devoloper or programmer. Pull
request means for-merging-request.
"Pull"(i.e fetch and merge) is the action
of requesting someone to see and
merge your code with the main data or
main code(primary one).
It lets you tell others about changes
you've pushed to a branch in a
repository on GitHub.

(About github)- It is a website whihc is used to store and manage their code by
using git. By giving information of our projects
we may include our github account link. We upload any project in the
form of folders and in the terminology of
github we say repositories and in short form it is known as repos.
*(README)- It is a special type of file which is used for storing the
information about the project or say the repo.
*(Repo)- Collection of files which makes a project as whole.

(some facts)-
*HttPS is one of the most easiest way of cloning any repo.
*There would always be a file named <.git> whenever git is tracking that
file.
*README file is a (mark down) file.
*To tell the git to not to track any file or folder that w want, we use a
special file called .gitignore.
*You can use HTML features in your [Link] file to ornamate the [Link].
*The red theme statments which occures after using <git branch -a> are those
branches which are connected with remote server
*It becomes easier to make the repo at GitHub first then start the project
through our text editor.
*Once after creating a new branch, it directly does not connects with the
remote server but once you push anything from it then it
becomes part of the remote server.

--> Committing ths changes in GitHub is a two step process. First we add changes,
in simple we are staging the changes for modificatin
then we commit the changes to the launcher which is git with a message(-m).
Commiton of the changes is cpmpleted then we
command the git with the statement- <git push> to launch or say send the
changes to the github through the cloud server.

(Workflow)-
(at remote server- GitHub)-
GitHub-repo -> Cloning -> Changes(modification) -> add(staging) ->
commition -> push
(at local server- at our own system)-
File creation -> initialization(<git init>) -> changes(modification) ->
add(staging) -> commit(message)

(Components of a [Link] file)-


1. Project title.
2. Description.
3. Installation instruction.
4. Usage.
5. Features.
6. Table of contents.
7. Technologies used.

(Important definitions)-
->(Commit Hash)- It is a special code or id of a commit that has been
commited to every staged changes in git.
->(Important definitions)- A fork is a new repository that shares code and
visibility settings with the original "file or say
upstream" repository. Fork is a rough copy.4

(important points)-
*Branch change leads to the change in the workflow of the text-editor pannel.
If we change the branch then the code also
changes if the code of the different branches are different.
*If we want to merge any branch with another brench then we can do it without
giving any message-
(Steps of merging branches in short cut)-
->Use the command~ <git merge "branch-name">
->Merge- [Link] named file would flash, just quit it.
->After closing the window, what number of insertions and deletions
have been done shows out. This shows that the
changes of another branch has been added(merged) to yoout main or
default branch.
->Use the command- <git push> for pushing the changes of the main or
default branch which you have merged.
->And the changes have been added to the main or default branch from
the desired branch which the user wanted to merge
with the main or default branch.
*The command of <git reset "file-name"> and <git restore "file-name"> is the
same thing only. <git reset "file-name"> is like
the synonym of <git restore "file-name">.
*All the commits of any file are stored in a series. The lastest commit is
by-default named as HEAD.

(Merging concepts)-
Merging is basically about the joining or say the merge of two or more then
two different-different branches.
There are two different ways of merging-
1. (By command)- This types of merging takes place when we are in our
own system files or project management, where
wide range of people are not involved.
This is further of two types-
1. (Merging without any message)- In this, we merge
by not giving any sort of message that
why we are merging the
respective branch with the main
branch. It is a direct
way of merging.
*The steps of direct merging are written in the
second point of the <imortant points>
sections.
2. (Merging with a message)- In this type of merge,
we give me a message in a txt file where we
would be depicting thag why
we are merging the respective
with the desired branch. This
includes a lengthy process.
2. (pull request)- This type of merging is done when a person is linked
with a wide range of peoples, specially when
he is engaged in a project. Wide range of people are
engaged in coallation projects. Each of
the member have his own branch where he pushes or
contributes his contribution through his own
branch. If he wants to merge his branch with the main
work space then he sends a request to the
project manager with a cause or say the message of
merging, what changes have been done and
what is the workflow. Then the project manager
approves the merge(if the changes is useful or
necessary). This process of merging and sending pull
requests is known as merging by pull
request.
(command for merging)- <git merge "name_of_the_branch">.

You might also like