Skip to content

Instantly share code, notes, and snippets.

@algotrader-dotcom
Last active July 28, 2021 06:41
Show Gist options
  • Select an option

  • Save algotrader-dotcom/177c67341b1303095aa8 to your computer and use it in GitHub Desktop.

Select an option

Save algotrader-dotcom/177c67341b1303095aa8 to your computer and use it in GitHub Desktop.
Git and Github in 5 minutes
# Git and Github in 5 minutes
1. First of all, you need to create a git project like this:
git init learn-git
cd learn-git
Then, once you are in a git repository, you start writing the initial draft of the code.
file: helloword.php
<?php echo "Hello World!\n"; ?>
2. Everything looks fine till now. Time to add the code to git:
git add .
git commit -m "Importing all the code"
"commit" means to save your changes. First time, it creates a master branch, which is the main branch.
Now edit (or add/remove files in current dir) your hellworld.php as
<?php echo "Hello World! Changed!\n"; ?>
3. To update your changes to the master branch, commit your changes again:
git commit -a -m "Update code"
4. To verify and check whether the changes you made actually made it to git or not, check the log:
git log
...
Now you have everything ready to work on your local computer. In order your teammates work on the same stuff. For this, you need to create a remote repository. Github is your gateway to create your own repo. Once you create your account on github, you can create the repo over there
5. Finally, add your files on to the remote repo too and push!
git remote add origin https://github.com/mohitdhingra/learn-gi.git
git push -u origin master
Username for 'https://github.com': your-email-on-github@gmail.com
Password for 'https://your-email-on-github@gmail.com@github.com':
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% 7/7, done.
Writing objects: 100% 8/8, 18.47 KiB | 0 bytes/s, done.
...
Branch master set up to track remote branch master from origin.
## References
http://functionspace.com/articles/54/Understand-Git-and-Github
http://www.thegeekstuff.com/2011/08/git-install-configure/
#### ***** It's better to setup SSH key (ssh-gen-key then copy public to add to to github) *****
git clone git@github.com:thuannvn/nodejs-start-stop-script.git
Add/update/edit files to nodejs-start-stop-script directory
git add .
git commit -m "First commit"
unset SSH_ASKPASS
git push origin master
@zzkpumc
Copy link
Copy Markdown

zzkpumc commented Jul 28, 2021

Great! Truly worthy of a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment