The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,091 other followers

version control – How do I do an initial push to a remote repository with Git? – Stack Overflow

Posted by jpluimers on 2020/04/30

Based on [WayBack] version control – How do I do an initial push to a remote repository with Git? – Stack Overflow, this is what I do:

On the server

mkdir my_project.git
cd my_project.git
git --bare init

On the client

mkdir my_project
cd my_project
touch .gitignore
git init
git add . git
commit -m "Initial commit"
git remote add origin youruser@yourserver.com:/path/to/my_project.git
git push --set-upstream origin master

The last one is important, especially when you have multiple remotes.

Some servers allow you to skip the server part, as they run them automatically when pushing a new repository from the client.

This can be both an advantage and a disadvantage, for instance when you have typos when adding the remote.

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: