Step-By-Step Guide To Push Your First Project On GitHub!!

Akash Rajvanshi
HackerNoon.com
6 min readApr 26, 2019

--

Steps that can make your work half!!

Photo by Samuel Zeller on Unsplash

First select your project & open your terminal in your project’s root directory.

1. Check for Git Version

If it is not showing the version of git then go to the official website of git and download the git according to OS of your system.

2. If we are setting up the git for the first time, we can configure the git with name & email.

3. Initialize Git Repository

Note:- On your Project’s root directory

It initializes the git repository in local project & will make .git folder that contain important folders and files.

4. Commiting files into the git repo.

There are three steps :-

Step 1 : We need to add a file to staging area .

Note :- In place of <File_Name> add your file and if you want select all the files in current directory then use {{ . }} or {{ * }}

Staging area :- Staging area is that area where we can buy some items and put them in bucket .

To check,if files are added or not,use this:

Step 2 : Commit a file into the git repo is to write a commit message.

m = message

Note :- In the “Double Quotes”, you should write your message.

Step 3 : Push the file into a remote repository. {{Github}}

Now create your account on git-hub and create a repository .

To add files in your remote repo use this :

Note :- This above command is a single command & Now place your git-hub username (without any quotes) and put your repository name (without any quotes).

Like this

And if you don’t understand this then go to your repository on git-hub and click on clone or download button and copy url with SSH method.

To check

5. Create SSH Key.

Why we use SSH?

By using the ssh protocol, we can connect and authenticate to remote servers and services. With ssh keys we can connect to GitHub without supplying our username and password at each visit with the help of passphrase.
In HTTPS method, you will need to fill our username and password at every visit, which will be very inconvenient.

Git associates a remote URL with a name and our default remote is usually called “Origin

1. Generating New ssh key and adding it to a ssh agent.

Note :- Place your email in “double quotes”.

This creates a new ssh key using the provided email as a label.

1.1. For default file Press {{ ENTER }}

1.2. Enter a passphrase.

1.3. Now our identification has been saved in

2. Adding our ssh key to the ssh agent

3. Now we add SSH Private key to ssh-agent to our default path.

4. Adding a new ssh key to your github account.

Copy the ssh key to our clipboard.

  1. Automatic Method (Using Xclip)

2. Manual Method

Now goto github.com ➢➢ Under Profile Photo (Drop Down) ➢➢ Settings ➢➢ Use SideBar {{ SSH & GPG Keys }} ➢➢ Then go to this directory on your computer {{Home/.ssh/id_rsa.pub}}
Open this file and copy your key.

Create new SSH key ➢➢ Title the filed with descriptive label ➢➢ Paste key into a “Key Field” ➢➢ Click on {{ Add SSH Key }}

5. Now for Testing SSH Connection.

After running this , it will show this messege on terminal!!

6. Final PUSH

Note : Change ‘master’ whatever branch to push.

Then you can successfully push your file to remote server and you can setup a SSH Connection.

To check the connection

Some other useful git concepts.

There are concepts that can help you to understand the git more deeply.

1. Create a new branch.

If you want to switch back to master branch.

If you want to delete the branch.

2. Update and Merge.

To update local repository to the newest commit

To merge another branch in active branch.

In both cases git tries to auto-merge changes. unfortunately this is not always possible and results are in conflicts.

we can merge those conflicts manually by editing the files shown by git.

Before merging changes we can preview.

3. Tagging.

we can give tag (line 1.0.0)

Note : {{ this is the first 10 characters of commit id. }}

4. Git Log.

By Git Log we can study repository history.

Advanced :

  1. See only the commits of a certain author.

2. Very compressed log.

More preferable format

3. It will only show the files that have changed.

5. Replace Local Changes.

(if we did something wrong) then this will replace file with the last content in HEAD.

If we want to drop all local changes and commits, fetch the latest history from server

6. Never forget to create your .gitignore file.

Gitignore file ➢➢ Is a file that specifying the files or folders that we want to ignore.

There are several ways to specifying those

  • Firstly, you can specifying by the specific filename. Here is an example, let’s say we want to ignore a file called readme.txt, then we just need to write readme.txt in the .gitignore file.
  • Secondly, we can also write the name of the extension. For example, we are going to ignore all .txt files, then write *.txt.
  • There is also a method to ignore a whole folder. Let’s say we want to ignore folder named test. Then we can just write test/ in the file.

Like this

.gitignore file

Useful Hints

1. Built in git Gui.

2. Use colorful-git output.

3. Use interactive adding.

Photo by Pankaj Patel on Unsplash

Lastly, You are requested to share your views on this article. :)

Find something useful? Hold down the 👏 to support and help others find this article. Thanks for reading!!

Follow me on Instagram @hypnosisss___ :)

--

--