Creating a git Repository?

972    Asked by TanuBakshi in Devops , Asked on Nov 10, 2019
Answered by Tanu Bakshi

 Create a /path/to/my/codebase/.git directory.

$ cd /path/to/my/codebase

$ git init

 Add config file to GitIgnore

Create .gitignore file and add config file the related to system dependent

 Add all existing files to the index.

$ git add . 

 Record the pristine state as the first commit in history

$ git add . 

Now create a repos on Github or Bitbucket

Now, create a new repository on Github or bitbucket named test. Once you created a repository, you will get a remote URL, It will seem like below. It could be SSH or HTTP. In this example we are taking HTTPS. URL likes – https://xxxxxxxxxx@bitbucket.org/xxxxxxxxx/test.git.

5. Add Remote in Git

Now using this url add the remote in git. Let’s move to terminal and run this command

$ git remote add origin https://xxxxxxxxxx@bitbucket.org/xxxxxxxxxx/test.git

// replace url to own repo url

Finally, push the all code into server repo

$ git push -u origin master



Your Answer

Interviews

Parent Categories