{"id":14046,"date":"2022-01-18T18:28:28","date_gmt":"2022-01-18T18:28:28","guid":{"rendered":"https:\/\/linuxways.net\/?p=14046"},"modified":"2022-01-18T18:30:26","modified_gmt":"2022-01-18T18:30:26","slug":"how-to-push-a-project-to-remote-gitlab-using-git-on-linux-mint-20","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/mint\/how-to-push-a-project-to-remote-gitlab-using-git-on-linux-mint-20\/","title":{"rendered":"How to Push a Project to Remote GitLab Using Git on Linux Mint 20"},"content":{"rendered":"<h2>What is Git?<\/h2>\n<p><a href=\"https:\/\/git-scm.com\/\">Git<\/a> is open-source software that is designed to track changes in everything, from small to large projects with high speed and efficiency. It is a version control system usually used by developers\/programmers for work collaborations while developing source code during software development.<\/p>\n<p>In this guide, you will see how you can push a project from your local machine to GitLab. For this, you need git installed and configured on your local machine. We are using Linux Mint 20 as the operating system in our local machine. You also need to have a <a href=\"https:\/\/gitlab.com\/users\/sign_in?__cf_chl_jschl_tk__=HazvUi5nM3UNQwu_B8YV8GCKA2s99ABmz.xaPec9A4o-1642422113-0-gaNycGzNC6U\">GitLab<\/a> account to push your project.<\/p>\n<p>With further ado, let\u2019s get started!<\/p>\n<h2>Step 1: Create an empty project<\/h2>\n<p>First of all, let\u2019s create an empty project in our local machine. I have created a My Projects directory on the desktop. In this directory, I will be creating a project here to push to GitLab.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"336\" height=\"545\" class=\"wp-image-14047\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-370.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-370.png 336w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-370-185x300.png 185w\" sizes=\"auto, (max-width: 336px) 100vw, 336px\" \/><\/p>\n<p>Inside Myprojects, I have created a project with the name Project1. This is the project I will push to GitLab.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"384\" height=\"504\" class=\"wp-image-14048\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-371.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-371.png 384w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-371-229x300.png 229w\" sizes=\"auto, (max-width: 384px) 100vw, 384px\" \/><\/p>\n<h2>Step 2: Open Project directory in terminal<\/h2>\n<p>Now, open your terminal and go to the project\u2019s directory with the cd command.<\/p>\n<pre>cd \u201cproject\u2019s path\u201d<\/pre>\n<pre>cd \/home\/azifa\/Desktop\/Myprojects\/Project1<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"470\" height=\"21\" class=\"wp-image-14049\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-372.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-372.png 470w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-372-300x13.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/p>\n<h2>Step 3: Initialize project<\/h2>\n<p>Now that you are inside the project, initialize the project using the following command:<\/p>\n<pre>git init<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"407\" height=\"15\" class=\"wp-image-14050\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-373.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-373.png 407w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-373-300x11.png 300w\" sizes=\"auto, (max-width: 407px) 100vw, 407px\" \/><\/p>\n<p>After this, your project repository will be initialized and you will get the following confirmation:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"19\" class=\"wp-image-14051\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-374.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-374.png 650w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-374-300x9.png 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>This means that now your project will be able to be tracked with git. You will also see a .git folder after initialization. If you cannot see it, go to view and tick the view hidden files box. Now you will be able to see it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"446\" height=\"384\" class=\"wp-image-14052\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-375.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-375.png 446w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-375-300x258.png 300w\" sizes=\"auto, (max-width: 446px) 100vw, 446px\" \/><\/p>\n<h2>Step 4: Check project\u2019s status<\/h2>\n<p>Check the status of your repository by running the following command:<\/p>\n<pre>git status<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"426\" height=\"16\" class=\"wp-image-14053\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-376.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-376.png 426w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-376-300x11.png 300w\" sizes=\"auto, (max-width: 426px) 100vw, 426px\" \/><\/p>\n<p>It will tell you which branch you are on. We are on the \u201cmaster\u201d branch. And there are no commits yet. This means that there are no changes or files in the project to be committed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"86\" class=\"wp-image-14054\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-377.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-377.png 564w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-377-300x46.png 300w\" sizes=\"auto, (max-width: 564px) 100vw, 564px\" \/><\/p>\n<h2>Step 5: Create an empty file in project directory<\/h2>\n<p>Next, I will create an empty file \u201cText.txt\u201d in \u201cProject1\u201d directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"565\" height=\"538\" class=\"wp-image-14055\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-378.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-378.png 565w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-378-300x286.png 300w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/p>\n<h2>Step 6: Check the status<\/h2>\n<p>Now if I check the status of the project, it will show a file that is untracked that we just created.<\/p>\n<pre>git status<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"527\" height=\"136\" class=\"wp-image-14056\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-379.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-379.png 527w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-379-300x77.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/p>\n<h2>Step 7: Add file to git<\/h2>\n<p>To add this file to git, run the command:<\/p>\n<pre>git add filename<\/pre>\n<pre>git add Text.txt<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"19\" class=\"wp-image-14057\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-380.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-380.png 468w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-380-300x12.png 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/p>\n<p>Let\u2019s check the status of the project with the command we used before. Now, it is showing the file in green which means the file has been added in git. Now it is ready to be committed.<\/p>\n<pre>git status<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"476\" height=\"144\" class=\"wp-image-14058\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-381.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-381.png 476w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-381-300x91.png 300w\" sizes=\"auto, (max-width: 476px) 100vw, 476px\" \/><\/p>\n<h2>Step 8: Commit changes<\/h2>\n<p>Now to commit our changes, we will use the following command:<\/p>\n<pre>git commit -m \"msg\u201d<\/pre>\n<p>In the message, you can write something meaningful that everyone can follow.<\/p>\n<p>After running the command, you will see a confirmation that your commit is done.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"69\" class=\"wp-image-14059\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-382.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-382.png 608w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-382-300x34.png 300w\" sizes=\"auto, (max-width: 608px) 100vw, 608px\" \/><\/p>\n<h2>Step 9: Copy clone URL<\/h2>\n<p>Now go to your GitLab account, and go to the project.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1313\" height=\"638\" class=\"wp-image-14060\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-383.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-383.png 1313w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-383-300x146.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-383-1024x498.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-383-768x373.png 768w\" sizes=\"auto, (max-width: 1313px) 100vw, 1313px\" \/><\/p>\n<p>Inside it, you will see no changes. That is because we have only committed our changes but have not yet pushed them to GitLab. To push the changes, go to clone and copy \u201cclone with https\u201d URL. I will show it in the next step.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"377\" height=\"394\" class=\"wp-image-14061\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-2.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-2.jpeg 377w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-2-287x300.jpeg 287w\" sizes=\"auto, (max-width: 377px) 100vw, 377px\" \/><\/p>\n<h2>Step 10: Push the changes<\/h2>\n<p>To push the changes to GitLab, run the command mentioned below. In place of origin, give the URL you copied in the previous step. Replace branch with the name of the branch in the syntax mentioned below. In my case, it is \u201cmaster\u201d.<\/p>\n<pre>git push origin branch<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"858\" height=\"20\" class=\"wp-image-14062\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-3.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-3.jpeg 858w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-3-300x7.jpeg 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-3-768x18.jpeg 768w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\" \/><\/p>\n<p>After running the command, you will be asked to type your username of GitLab account, as well as your password to get access.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"470\" height=\"35\" class=\"wp-image-14063\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-384.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-384.png 470w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-384-300x22.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/p>\n<p>With the right credentials, you will get access and the repository changes will be pushed to GitLab. You will get the following confirmation:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"101\" class=\"wp-image-14064\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-385.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-385.png 493w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-385-300x61.png 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><\/p>\n<p>Now go to your GitLab account, and open the project. You will now see changes that you made in the local repository.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1037\" height=\"555\" class=\"wp-image-14065\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-386.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-386.png 1037w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-386-300x161.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-386-1024x548.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-386-768x411.png 768w\" sizes=\"auto, (max-width: 1037px) 100vw, 1037px\" \/><\/p>\n<p>That was all, guys.<\/p>\n<p>In this detailed guide, you saw how to push changes in our local project repository to GitLab with the help of a few easy-to-follow git commands. Like this, you can collaborate with your fellow developers for work without running into errors.<\/p>\n<p>To see how you can install and configure Git on Linux Mint 20, visit:<\/p>\n<p><a href=\"https:\/\/linuxways.net\/de\/mint\/how-to-install-and-configure-git-on-linux-mint-20\/\">https:\/\/linuxways.net\/mint\/how-to-install-and-configure-git-on-linux-mint-20\/<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>What is Git? Git is open-source software that is designed to track changes in everything, from small to large projects with high speed and efficiency. It is a&hellip;<\/p>","protected":false},"author":1,"featured_media":14143,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[475,220,129],"class_list":["post-14046","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mint","tag-git","tag-gitlab","tag-linux-mint-20"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/14046","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=14046"}],"version-history":[{"count":1,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/14046\/revisions"}],"predecessor-version":[{"id":14066,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/14046\/revisions\/14066"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/14143"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=14046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=14046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=14046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}