Push your code to the remote Git branch

Photo by Roman Synkevych on Unsplash

If you wish to push the code in your local computer system to a particular branch in remote, then this article is for you. Follow the steps below.

  1. Add a .gitgnore file [The files and directories mentioned in this file will not be pushed to the remote]
touch .gitignore

2. Initialise git. This command will add a .git file to your local directory

git init

3. Add the files to be committed to the remote code

git add .

4. Add a commit message

git commit -m "Initial commit"

5. Add it to the remote repository

git remote add origin youruser@yourserver.com:/path/to/my_project.git

6. Push it to the master

git push origin master

7. If you wish to push it to some other branch instead of master, run the following command.

git push origin HEAD:<your_branch_name>

--

--

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
Allwin Raju

Allwin Raju

Python Developer | Django Developer | Python Enthusiast