DEV Community

Cover image for How to push a code in GitLab?
Sevaki Rajasekar
Sevaki Rajasekar

Posted on

How to push a code in GitLab?

Hey everyone! Welcome to my another blog!
Today we are going to discuss about how to push our code to GitLab in a brief way.
*What are things we should do while "sign in" in GitLab *

  • Do not click "free trial". Because there are some issues to sign in to your account after that you every time log in. Then you have to recreate your account with a different email without any option.

  • You have to note down or save your 'username' and 'password' for your account. You can recover your account, but it will take time, that will irritate you.

How to push our code?

After successfully login in to our account, we can start pushing our code.
*Push a code means = Save/Store our code in GitLab *
Now we will see the procedure step by step,

Step-1: Create and set the Group and Project environment:

  • Before pushing the code, we have to change the groups and projects status from private into public.
  • For groups = Groups > xxxx-group > Settings > General > public > save changes. The same procedure for projects.
  • After creating a group and project click, code(blue button) > Copy URL (in Clone with HTTPS).

Step-2: Create Git folder in our local repository:

  • Now, go to your files, create a new folder. Open terminal by right-clicking on that folder.
  • Comment to terminal "git clone" and paste that copied URL.

Step-3: Getting ready our file:

  • Now that the cloned file will appear in that folder which was made before.
  • Click that folder and copy our code file into that folder. *Note: Your first file name should be like "index.html".

Step-4: In Terminal:

  • Now we can check whether that new file is recognized or not.
    For that, give "git status" command. That new folder will be visible in terminal in Red color.
    Image description

  • For adding that file, give "git add ." (If you have one new file or many files, you can mention dot, (".") means all files. Now your new files will appear in Green color.

  • Then give "git commit -m "(Mention what are you going to do with this file(Ex: Want to save my file)" ".

  • Finally give "git push" command. It will ask your GitLab Username and Password, fill those without any mistakes.

Image description

*Note:

  1. " "(double coats means commands .you don't need to type that.
  2. Don't use any spaces in commands, type as like me.
  3. If you make any mistakes in terminal part, you can clear and start from the first.

So that's guys. Many of you already know this, but I hope it will be helpful for beginners. Let me know if I made any mistakes. Will see in my next blog.

Top comments (0)