GitHub is essential to many web and app development businesses as it can provide hosting for software development and version control using Git. You can use GitHub in various ways including website, app, or terminal. The terminal is the best way to sync local projects to a GitHub repository, and once you learn the basics, you'll be able to push local projects to remote GitHub repositories in seconds. To upload your code into GitHub, you need to push the code to GitHub.
How to Push to GitHub?
First, you will need to install Git on your system or Git Bash if you’re using Windows. You can download them from the Git website. Once Git is set up, go to the web page for your GitHub repository and note the URL.
Now open Git Bash on Windows.
Use the “cd” command to switch to the directory you want to push to the GitHub repository. Then, start the Git process by typing the command: “git init”.
You will also need to add configure your GitHub id using the following commands:
git config --global user.email "firstname.lastname@example.org"
git config --global user. name "your user name"
Next, you need to make your first commit using the command:
git commit -m "first commit"
Use this command to add the code files to the server: git add.
Then, use the following command: git branch -M main
You've just committed the first Git code locally. Now you need to upload it to your GitHub repository. Use the URL of your repository and .git to the URL for the following command. Before the URL, you should also enter a nickname for the repository so it becomes easier to push to it in the future.
git remote add <project nickname> <project URL>.git
Next, see if it worked by using the following command: git remote
You can also add the -v or --verbose command to the above command to print the URL, so you can verify not only that the remote was created, but also that the URL is correct.
Now you can push the contents of the directory to the GitHub repository using the following command:
git push -u <project nickname> main
This will take all the files and folders from the directory and upload them to the repository. Now you can open the GitHub repo web page and you'll see all the details there.
How to Automate GitHub with Appy Pie Connect?
Appy Pie Connect lets users integrate GitHub with more than 150 apps, so you can automate more of your Git processes. For example, you could new GitHub pull requests to Slack as new messages, or create Trello Cards from Github Pull Requests.