December 1, 2019

How to add a local project to git/azure repo using git bash

  December 1, 2019
Whether we are using an eclipse or Visual studio we can always add our project to git repo without the help of IDE.

Git Bash is such a tool where we can do all git operations without any IDE.

You can download Git bash from here https://git-scm.com/downloads

Now below are the basic steps to add a new folder in the local PC to git repo.

For that first, we have to go to the folder which contains our project.
  1. Right-click on the folder which contains the needed project.



This will open the git bash terminal.
  • Enter git init command in the terminal and press enter
git init

This will create a .git folder outside the project to add.


Now follow the below steps by entering each command in the terminal.

  • Select to add all the files to the git repo (git<space>add<space>.)
git add .

  • Now commit these file to the local repo by giving a comment
git commit -m "adding files - Automate Future"

  • Now we need to make a remote connection to the git repo we created from our local system.
git remote add origin https://github.com/<Username>/AutomateFuture.git

we can find the repo URL from the Github website once the repo is created.


  • As we now made the connection to the online repo, we need to push the files.
Before that in most cases we may need to set SSL verify as false, So run the below command first. (If any error is thrown)

git config http.sslVerify false


We may get the below error if there is any pending commit already exists in the origin to pull.

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

[If the Repo is already created, it is good to do a pull before push]

git pull origin master --allow-unrelated-histories

Now we can push the code.

git push -u origin master

This will push the code to the master branch of the repo.

The final terminal will look almost like this.


logoblog

Thanks for reading How to add a local project to git/azure repo using git bash

Previous
« Prev Post

1 comment:

Fixing javascript error: Cannot read properties of null (reading 'querySelector') issue when using CSS identifier in selenium

 JavaScript is another way to interact with web elements when normal selenium methods fail to act. But one issue with javascript is, it does...