Many Minds
Published in

Many Minds

Initialize git, add remote origin and to set default upstream

git init

The git init command creates a new Git repository. It can be used to convert an existing, unversioned project to a Git repository or initialize a new, empty repository. Most other Git commands are not available outside of an initialized repository, so this is usually the first command you’ll run in a new project.

git remote add origin {REMOTE_URL}

To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at.

The git remote add command takes two arguments:

  • A unique remote name, for example, “my_awesome_new_remote_repo”
  • A remote URL, which you can find on the Source sub-tab of your Git repo

For example:

#set a new remote
Two ways,
1.git remote add my_awesome_new_remote_repo git@github.com:NilukaSripalim/flutter-mobile-app.git
# or
2.git remote add origin https://github.com/NilukaSripalim/flutter-mobile-app.git
#Verify new remotegit remote -v> my_awesome_new_remote_repo git@github.com:NilukaSripalim/flutter-mobile-app.git (fetch)
my_awesome_new_remote_repo git@github.com:NilukaSripalim/flutter-mobile-app.git (push)
origin https://github.com/NilukaSripalim/flutter-mobile-app.git (fetch)
origin https://github.com/NilukaSripalim/flutter-mobile-app.git (push)

3.

git pull origin master

To push your changes into your remote repo, execute the git push <remote> <branch> command:

4.

git branch -u origin/branchName
# or
git branch --set-upstream-to=origin/master master

You update/set an upstream with the branch command. Branch branchName set up to track remote branch branchName from origin.

You can also set it with a push

git push -u origin master
git push --set-upstream origin master

5.

git pull

It fetches and merges changes from the remote server to your working directory. The git pull command is used to pull a repository.

--

--

--

The idea is to learn something for myself and share what I have learned.

Recommended from Medium

How I learned to manage a Data Science team in 2 days

Xamarin.Forms System.ArgumentException: Illegal characters in path

Using Kubernetes to orchestrate dbt on Snowflake with Github actions

Looking to make the most of kubernetes?

Coding On The Go

Deepnote: How to set up a PostgreSQL database in the cloud and connect

Lead Enrichment APIs Guide To Developers In 2022

ASP.NET Core MVC with Docker introduction

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niluka Sripali Monnankulama

Niluka Sripali Monnankulama

An IT professional with over 3 years of experience. Member of the WSO2 Identity & Access Management Team.

More from Medium

Git Add -P: A Scalpel for Your Commits.

Release the limits of Github Actions with self-hosted runners

Elegantly Handling Dependency Fails