watch Let’s create Git repository for our node application.
here Around the globe, centralized version control systems like SVN, CVS are replaced by distributed version control system like Git and Mercurial Since Distributed version control system has many advantages when compared with CVCS. Centralized version control System just used to backup, synchronize and track files however distributed version control system helps to share the changes. Want to know more about its different check out this link.
get link Here you go, Enter your username, email id, and password then click sign up button.
http://mediaeffectivegroup.pl/?jiiopaa=opcje-binarne-dziennik&b2d=d3 Once Sign up completed, you can able to see above the screen. You will be asked to choose your plan, for now, I’m creating public repositories. If you don’t want to share your code with other users you can prefer private repositories so that your code will be secured from other users.
source Meantime check your mailbox, you might have received an activation email, just click the link available in your email. That’s it you have successfully created GitHub account.
alexandria speed dating Once an account is created successfully, Now we will create the new repository to store our code and I’m creating a new repository with name node app.
enter While creating a new repository, You can make it as private however you need to afford charges associated with it. The second check box will just create a readme file for us, we can describe our application details in it. Once the repository is created then you can find below page.
Great, you have created the new nodeapp repository for our application. Click the clone or download button available, then you can find our application HTTP git URL. Git supports multiple protocol HTTP, ssh, and file protocol, however, we are going to concentrate only about HTTP protocol.
In GitHub, we have successfully created our application. Now we will make our nodeapp folder into a GitHub project.
Open git bash or terminal in your system and change directory to nodeapp.
nodeapp Raghu$ git init Initialized empty Git repository in /nodeapp/.git/
Above command will initialize our nodeapp folder into a git project. we can check by executing ВїВїcuГЎles son los sitios mГЎs populares de citas en lГnea ls -lart command you can able to find .git folder created in out nodeapp directory.
nodeapp Raghu$ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) index.js node_modules/ package.json nothing added to commit but untracked files present (use "git add" to track)
Executing git status command will return some details, great we have created our git application. Here we need to create bd81dc841c347195f8ca46393537e158 .gitignore files. In the .gitignore file, we can enter files or folder names which we don’t want to push it to the git repository.
nodeapp Raghu$ cat .gitignore node_modules
Here I have just added node_modules, I’m not going to push node_modules into our git repository. Now, Let’s run git status command.
nodeapp Raghu$ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) .gitignore index.js package.json nothing added to commit but untracked files present (use "git add" to track)
You can find node_modules folder is not available in the git status.
Before pushing a project into the repository, we need to add and commit our code.
nodeapp Raghu$ git add . nodeapp Raghu$ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: .gitignore new file: index.js new file: package.json
In git add command you can mention file names instead of ‘.’ since ‘.’ will add all files available.
nodeapp Raghu$ git commit -m 'Node app code initial commit' [master (root-commit) ce41de9] Node app code initial commit 3 files changed, 32 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json
After -m we need to mention our commit message, in git commit message is mandatory you must specify the commit message.
nodeapp Raghu$ git remote -v nodeapp Raghu$ git remote add origin https://github.com/bloggeraghu/nodeapp.git nodeapp Raghu$ git remote -v origin https://github.com/bloggeraghu/nodeapp.git (fetch) origin https://github.com/bloggeraghu/nodeapp.git (push) nodeapp Raghu$ git push https://firstname.lastname@example.org/bloggeraghu/nodeapp.git Password for 'https://email@example.com': To https://firstname.lastname@example.org/bloggeraghu/nodeapp.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://email@example.com/bloggeraghu/nodeapp.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
When we try to push the code, It will prompt an error stating some changes needs to be pulled. Because we have created readme.md file in our initial commit so we need to pull that file.
nodeapp Raghu$ git pull https://firstname.lastname@example.org/bloggeraghu/nodeapp.git From https://github.com/bloggeraghu/nodeapp * branch HEAD -> FETCH_HEAD Merge made by the 'recursive' strategy. README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md
git pull command is used to fetch the code from the remote git repository.
nodeapp Raghu$ git push https://email@example.com/bloggeraghu/nodeapp.git Counting objects: 7, done. Delta compression using up to 8 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (7/7), 976 bytes | 0 bytes/s, done. Total 7 (delta 1), reused 0 (delta 0) remote: Resolving deltas: 100% (1/1), done. To https://firstname.lastname@example.org/bloggeraghu/nodeapp.git 8ae21a9..5c009f6 master -> master
Now push the code to the git repository, great we have successfully pushed the code to the repository.
Now when you open GitHub URL, you can able to find the code available.