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

CompleteGt GitHubTutorials

The document discusses how to use Git and GitHub to track changes to project files over time. It explains initializing a Git repository, checking file status, staging and committing files, viewing commit history, branching, and pushing code to GitHub.

Uploaded by

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

CompleteGt GitHubTutorials

The document discusses how to use Git and GitHub to track changes to project files over time. It explains initializing a Git repository, checking file status, staging and committing files, viewing commit history, branching, and pushing code to GitHub.

Uploaded by

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

References: Complete git and github tutorial

We have a project folder , now we have to maintain the history(new files created, changes made on
files and so on) of the files under this project folder how to do this

All of these history are stored in a folder that git provides us , it is called .git(hidden) folder

the .git folder is created by executing the command "git init" (intialize empty git repository)

contents of the .git folder are HEAD description info refs config hooks objects

How to check for committed and uncommitted files and which is the current branch in git ---> use the
command git status

uncommitted files are untracked files(not added to history or staging area) .. to add them to git
repository and track them git add . (. means all the files in the directory)

Red files are untracked files and Green files are tracked files (added to history or staging area)

to track a file( put into git history) you will have to commit it using the git commit

TO remove files which have already been committed from stage(staging area) use the command git
restore --staged filename

git log gives the list of all the commits made

git reset hashcode command is used to take you to some commit point (status at some point of
time)

git stash and git stash pop and git stash clear

two tasks : HOSTING YOUR PROJECT FOR FIRST TIME ON GITHUB FOR OTHERS TO USE
WE WANT A GITHUB URL (NEW REPOSITORY CREATED) TO BE ATTACHED TO OUR PROJECT(LOCAL
SOURCE CODE DIRECTORY) THE COMMAND USED IS

git remote add origin url

remote means u are working with url's

add -- means adding a new url

origin means name of the url you are going to add(nick name of the url is called origin)

git remote -v will list all the url's attached to the project folder

git push (to which url you want to push) ( and to which branch you want to push)

ex : git push origin master(or main) both are the same

You should never commit on the main branch(ideally). In practice a new branch is branched out from
the main branch and developers start committing on that branch

=============================

To create a new branch use the command

git branch feature (feature is the new branch name)

git checkout feature ( now HEAD which was earlier pointing to the main or master branch will point
to the feature branch)

head is just a pointer, all new commits you make will be added on the head, hence all the new
commits i am making will be added on the feature branch)
CHECKOUT COMMAND MEANS HEAD WILL POINT TO THAT BRANCH say
“Kunal” . All the commits now made will be made to “kunal” branch
Checkout is like steering of the car , where you change the steering you
change the direction, then you will apply breaks and do the commit in that
path of the road

What is difference between upstream and origin? – See 46.00.00

What is pick and squash 1:03:00

You might also like