Github

Setting A GMAIL AND NAME using git bash


git config --global user.name "your name here"
git config --global user.email "your gmail here"

Basic thing in git


Open the folder ,and open git bash here by clicking anywhere in the folder
After git bash is opened type "git status"
it will give you a message that "fatal:not a git repository:"
Now type "git init " to initialize this folder as a repository
Now if you type the git status then we will jget the files which are present in the folder
and it also show that the file is not tracked
Now track all the file using "git add --a" which will add all the files to the staging area
Now we have to commit using the command "git commit -m "initial commit"
Now if we do git status again it will say "there is nothing to commit,working tree clean"
Now to see the commmits we have made we use "git log" command
Now if you modify a single file and want to stage that only file we will use "git add file.ext"
Where file.ext is a file name
Now we will commit with a message by typing "git commit -m "your commit message"
Now you have successfully tracked files

Staging a file in github


To stage file all at a time you need to type the command
"git add --a"
followed by "git init" command
Every file has been staged


Using a gitIgnore folder


if we made some unnecessary folder there we dont want to
stage and commit on that folder we use the .gitignore file
type the file name on the *.gitignore file the file will be ignored
Now type "git add --a" to .gitignore to the staging area
Now lets commit by typing "git commit -m "added.gitignore"
if the code is modified then
if we use "git diff" command then it will show the difference between previous
and current file comparision.
again if we add "git add -a" and use "git diff" ,it will not show you anything
if we use "git diff --gitstaged " it will compare every commit with your working directory
Now let's skip the staging by typing “git commit -a -m “Commit Message””.
Now if we do “git status” it will show that the working directory is clean. Which means
we have successfully skipped the staging area and committed the changes.



Deleting the git files


we can delete files using git we need use this command:
"git rm filename.extension" it will delete all the file and if you do
"git status" Now the files has been deleted and staged Now we have to commit by using
"git commit -m "commit message"
To rename the file ,we have to use the command "git mv filename.extension renamefile.extension". It will rename the file from filename.extension to renamefile.extension and it will automatically staged by git now we have to commit the staged files



viewing and changing commits in gits


To see the commits made on the git repo, we need to type "git log". the all commit will arrive in the editor ,Now to exit this window we need to type "q" on our keyboard and press enter
To see the diff in commit we need to use "git log -p", it will show you what has been changed
To see the last two commits and changes we need to use "git log -p -2"


Changing a commit message


Now to change the most recent commit, we need to type "git commit --amend" and press enter. Then an editor will open where you can change the commit message and then you need to close it by pressing "esc" and then type ":wq"



Unstaging and modifying the files in git



To unstage a file ,we have to use "git restore --staged file.ext".it will unstage the file and we can verify it by using "git status"


Now lets say we have modified the unstaged file and made some change which are not necessary ,Now the program is not working we have to unstaged file and made some changes which were not necessary, Now the program is not working .To do it use "git checkout --file.ext ".
Now git will restore that files to its last commit state

To restore the entire working directory to the previous commit use "git checkout -f ",it will restore entire directory to the last commit


To create a another branch to avoid unauthorized changes to master branch
type command :"git branch new_branch_name"


For moving from the master branch to feature branch ,we use the following command: "git checkout Branch_name"

To list all the available branch present in git, we have to use this command: "git branch"

for merging the feature branch to master branch
use: "git branch feature1"


pushing a master branch


git intit
git branch -M master
first we have to copy the command like this "git remote add origin https://
git-------------"

and then after we have to type command
"git remote"
and thirdly input command :"git remote -v"
and then after type:"git push origin master"
when remote origin allready exist then type below command to :
git remote set-url origin
git push -u origin master
Hosting webstite
Modifying a github pages
git push