The world has changed a lot. In most projects that we work on, we like to use the latest technologies, may it be developing in an agile manner, using Kanban methods to make sure we have captured all the user stories, doing everything iteratively to ensure that the client is involved as well as they are part of the team. When it comes to implementation of solutions in programming, it is never a one-man team, rather it’s a bunch of people working together to achieve the same goal. Some might be in the same office, others prefer to work remotely, and others prefer to do pair programming. At the end of the day what matters is bringing all the information together(code) using a version control tool.
What does version control have to do with code integration? It has everything to do with it. Last week I was sharing a cup of coffee with my friend and he explained how his friends were exchanging code at work using flash disk. This could be tiresome right? How can integration be successful and seamless when everyone must meet physically to have the latest version of code?
When he asked them why they used flash disk to exchange code in a corporate setting compared to using Gitlab, GitHub or other version control tools available, their responses were
- They were not aware of the version control tools available
- Those who knew, didn’t have much knowledge about them or even how to use them
- Some had issues of getting everything to run
- Lastly, others had issues of joining the team late. They start working on their project locally only to realize the team has a remote repository late where they commit all their project code
Since the first three seems to be common, either it’s because of ignorance or lack of interest. I choose to address the last concern. I will be showing step by step how to add an already existing project to git repository.
STEP by STEP:
- In this point, I would like to assume that you have a repository in Git (which contains just a readme.md and a license maybe or other. gitignore files) and you have a local project that you want to push to Git. All projects should have a similar name.
Step by Step pushing an existing project to GitHub:
- Open the git bash and navigate to your project repository
- Initialize the local repository to make it a git repository
- Add all the files that you have in the local repository
- Check the status of all the files, if the files were added successfully they should be in color green else, they are in red color hence you should re-do the step
- Commit all the files that you have added
- Visit the GitHub site, and copy the HTTPS URL present in the repository
- In the git bash, still in your project folder, add the URL of the remote repository in GitHub where all your files will be pushed and verify it
- At this point, both our repositories have different histories. Hence, we need to pull and allow a merge of different histories.
- Push the changes from our local repository to GitHub
Happy git moment ?