Categories: GitHub

Adding an existing project to GitHub using the command line

<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<p>Step for existing project to GitHub using command line&comma; following steps are required to this&period;<&sol;p>&NewLine;<p><b>Step 1&colon;<&sol;b> Creating an account to the GitHub&period; Suppose<br &sol;>&NewLine;<b>Username for GitHub&colon;<&sol;b> myGitUser<br &sol;>&NewLine;<b>Password for GitHub&colon;<&sol;b> myGitPassword<&sol;p>&NewLine;<p><i>https&colon;&sol;&sol;github&period;com&sol;myGitUser&sol;<&sol;i><&sol;p>&NewLine;<p><b>Step 2&colon; <&sol;b>Access above url using mention username and password&period;<&sol;p>&NewLine;<p><b>Step 3&colon;<&sol;b> Create New Repository to your account&period; To avoid errors&comma; do not initialize the new repository with README&period; You can add these files after your project has been pushed to GitHub&period;<&sol;p>&NewLine;<p>Suppose your repository name&colon; <b>myRepository<&sol;b><&sol;p>&NewLine;<p><i>https&colon;&sol;&sol;github&period;com&sol;myGitUser&sol;myRepository<&sol;i><&sol;p>&NewLine;<div id&equals;"ads-id" align&equals;"center"><&sol;div>&NewLine;<p><b>Step 4&colon;<&sol;b> Installing GitBash to you machine&period; for this link <a href&equals;"http&colon;&sol;&sol;git-scm&period;com&sol;download&sol;win" target&equals;"&lowbar;blank" rel&equals;"noopener">http&colon;&sol;&sol;git-scm&period;com&sol;download&sol;win<&sol;a><&sol;p>&NewLine;<p><b>Step 5&colon;<&sol;b> After installing GitBash open the command prompt for Git&period;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2015&sol;03&sol;GitShell&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>Step 6&colon;<&sol;b> In the Command prompt&comma; change the current working directory to your local project&period;<&sol;p>&NewLine;<p><b>Step 7&colon;<&sol;b> Initialize the local directory as a Git repository&period; As follows<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2015&sol;03&sol;git-init&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>Step 8&colon;<&sol;b> Add the files in your new local repository&period; This stages them for the first commit&period;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2015&sol;03&sol;git-add&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>Step 9&colon; <&sol;b>Commit the files that you&&num;8217&semi;ve staged in your local repository&period;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2015&sol;03&sol;git-commit&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p>Commits the tracked changes and prepares them to be pushed to a remote repository<&sol;p>&NewLine;<p><b>Step 10&colon;<&sol;b> At the top of your GitHub repository&&num;8217&semi;s Quick Setup page&comma; click to copy the remote repository URL<&sol;p>&NewLine;<p><i>https&colon;&sol;&sol;github&period;com&sol;myGitUser&sol;myRepository&period;git<&sol;i><&sol;p>&NewLine;<p><b>Step 11&colon; <&sol;b> In the Command prompt&comma; add the URL for the remote repository where your local repository will be pushed<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2015&sol;03&sol;git-remote&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p>&num; Sets the new remote<&sol;p>&NewLine;<p><b>Step 12&colon;<&sol;b> Push the changes in your local repository to GitHub&period;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2015&sol;03&sol;git-push&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p>&num; Pushes the changes in your local repository up to the remote repository you specified as the origin<&sol;p>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;difference-between-git-add-a-and-git-add-dot-and-git-u&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '164'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago