How to Initialize a Git Repository Again

Initialize local git repository, push to the remote repository

  • Initializing the local repository
  • Create the remote repository in Github, bitbucket, Gitlab
  • Add the remote URL for local repository push button the initial commit

Github, Bitbucket, Gitlab

Cloud-hosted git servers publicly available to create the repositories for costless for individuals.

Git Local Repository

Now allow's initialize the local repository, Create the directory and initialize the directory as the git repository.

          mkdir my-first-git-repository             && cd "$_"
git init
Output
Initialized empty Git repository in ../my-starting time-git-repository/.git/
          .
├── branches
├── config
├── clarification
├── FETCH_HEAD
├── HEAD
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── fsmonitor-watchman.sample
│ ├── mail-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── pre-merge-commit.sample
│ ├── set up-commit-msg.sample
│ ├── pre-push button.sample
│ ├── pre-rebase.sample
│ ├── pre-receive.sample
│ └── update.sample
├── info
│ └── exclude
├── objects
│ ├── info
│ └── pack
└── refs
├── heads
└── tags
ix directories, 17 files
          echo "My offset modify" > firstfile.txt        
          git condition                      OUTPU            
On branch principal
No commits yet Untracked files:
(use "git add together <file>..." to include in what volition exist committed)
firstfile.txt
nothing added to commit just untracked files present (use "git add" to runway)
          git add together --all   # Add together all files in entire repository
# OR
git add . # Add all files in the current directory
# OR
git add firstfile.txt # Add specific file
          git status                      OUTPUT
On branch master
No commits yet Changes to exist committed:
(employ "git rm --cached <file>..." to unstage)
new file: firstfile.txt
          git commit -am "MY Showtime COMMIT"                      OUTPUT
[principal (root-commit) 945c423] MY Outset COMMIT
1 file changed, i insertion(+)
create mode 100644 firstfile.txt

Git Remote Repository

When to get remote repository

  • If there is more than one contributor
  • If you don't trust your machine deejay, it may get crashed anytime
  • Exchange the code alter between the servers for writing the code in IDE in dev machine, for deploy in the production server

Github — Create repository link

Github — Create Repository
  • We can import from different git server
  • requite the name of the repository — mandatory
  • Clarification of the repository
  • We need to opt for privet or public based on the projection accessibility
  • We can initialize repo with README.md, which is non recommended for the kickoff-timers
  • Add .gitignore if required, non recommended for starting time-timers
  • Add together LICENCE if required, not recommended for first-timers

Button existing repository to remote repository

#Option1 Create a new repository on the command line

          echo "# demo" >> README.doctor
git init
git add README.medico
git commit -m "first commit"
git remote add together origin https://github.com/JinnaBalu/demo.git
git push button -u origin master

#Option2 Push an existing repository from the command line

          > git remote add together origin https://github.com/JinnaBalu/demo.git
> git push -u origin main
          cd my-outset-git-repository/
git status
# OUTPU
# On co-operative chief
# nothing to commit, working tree make clean
git remote add origin https://github.com/JinnaBalu/demo.git
git push button -u origin master
# OUTPUT
# Username for 'https://github.com': JinnaBalu
# Password for 'https://JinnaBalu@github.com':
# Enumerating objects: iii, washed.
# Counting objects: 100% (3/3), done.
# Writing objects: 100% (iii/three), 247 bytes | 247.00 KiB/s, done.
# Total 3 (delta 0), reused 0 (delta 0)
# To https://github.com/JinnaBalu/demo.git
# * [new branch] master -> master
# Co-operative 'principal' prepare to track remote co-operative 'primary' from #'origin'.

          git log          # OUTPUT
# commit 945c423086e3b62bc2a504775d7b743ed51079f5 (HEAD -> main, origin/master)
# Author: Jinna Balu <jinna.balu@wisestep.com>
# Date: Thu Jun 18 09:25:26 2020 +0530
# MY Kickoff COMMIT

halcombablefte.blogspot.com

Source: https://jinnabalu.medium.com/initialize-local-git-repository-push-to-the-remote-repository-787f83ff999

0 Response to "How to Initialize a Git Repository Again"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel