Why GitHub is important
If you are in the software development industry, then, most likely you have heard about GitHub, a repository hosting service for Git that also has a web-based graphical interface. Today, I would like to discuss it and mention the key benefits you get from using Github.
Let's start
git is a version controls system like a history book for your code
file can go from a piece of work to a piece of … you get what I mean?
start form→
git init
now if you see the ‘U’ icon on to file name it means it is new to it or an untracked file
now here .git file is also created, as I mention in the node.js course too that if we clone the file from the repo will delete this file by ‘rm -force .git’
for downloading the npm packages in the repo-
npm install
it will uninitialized git from the project
install git lens extension in vs code if you don’t have it
create .gitignore file as you don’t want every file like node modules by →touch .gitignore
Now to take a snapshot or commit to the current directory
commit is like a page in a history book that has a unique key and can’t change without knowing about it
first thing to stage the file which we need to take in commit for that→
git add .
for unstage it
git reset .
you can upstage it by minus the symbol the on file in vs code and vice versa
tip==make small commits every time
for committing the (local repository)
git commit -m "sadasdasdasd"
but this happens on the master branch check by→
git branch
//will give all the existing branches
but if you need another branch for the experiment →
git checkout -b name
but you don’t have to commit before changing to the master branch
you can use stash as you finish half finish or work on it it will save it,
git stash -u
when you need it back in the working directory
git stash pop
it is an alternative to commit
now to merge the named branch to master
git merge name
you can squash the commit in a single commit this will change history nice and clean and concise
this is locally but remotely we can do it with GitHub
- create a new repo
- it will give you a command to run which will connect your local repo to the remote repo
git remote add origin HTTPS://....... .git
now to push it
git push -u origin master
now you will see your code on the git hub
pull request for open source
- fork the repo-will copy the repo and make it under your git hub account
- clone the forked repo-make changes to it
- install the npm install to install the dependency
- now can make a new branch by →git checkout -b mybranch
- now git add a to the staging area
- git commit -m “ ”
- and now git push it to the remote fork from the local machine
- now on GitHub, you’ll see the pull request, pull requests like merge but pulling my remote changes and merging them in the o master branch.
- and you are done with this good job!!!!
0 Comments