Skip to content

Instantly share code, notes, and snippets.

@danascape
Last active July 30, 2021 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danascape/84148ad46fd0af79c1b9ecc1477e6934 to your computer and use it in GitHub Desktop.
Save danascape/84148ad46fd0af79c1b9ecc1477e6934 to your computer and use it in GitHub Desktop.
In this guide we will learn pushing your code on git repository by using command line interface
If windows, then there is a git client you can install. then go to you workspace directory (where your files are)
* Right click and open git shell there.
If linux, then just to to your directoy and follow the steps.
* You need to initialise git in the directory such that git commands can be used inside.
git init
* After that you need to set your git config (to set that you are this specific user on git)
git config --global user.name=name && git config --global user.email=email
* For example, mine looks like this
git config --global user.name danascape && git config --global user.email danascape@gmail.com
* The username and email are your git names (obviously :D )
* Then create a repository on your git (https://github.com/new)
* Some options will be show up
* Like name and if you want it public or private
* Set those accordingly
* After you are done with that, return to your shell
* We need to first track the files we want to push. It can be done as :-
git add filename1 filename2 ....
or add all by
git add --all
* Then you need to commit info about the files you tracked (like what things you did inside, like setup script for this or that, etc)
git commit -m "some info about files"
* A editor will open up where you need to write your commit description (no need to touch the things written in # below empty lines)
then close your editor (vim, vi or nano, any is fine)
* After that you need to set your repository you made above on shell
git remote add origin(type-remote-name-here) repo-link
Then to push your work there
git push -u origin(your-remote-name) main(your-branch-name)
origin is your remote name and can be changed to any other (git remote add work repo-link)
main/master is set as default branch name and can be changed,
git checkout -b your-desired-branch-name
* So to push you'll need
git push -u your-remote-name your-branch-name
It'll ask you for credentials so you'll need to type that and your code will be pushed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment