My notes on how to use git

1) create a local git repo
$ git init
1.5) Save username and password for github
$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>

2) Add all the files in the currect folder
$ git add *
3) Commit the files/changes
$ git commit -m "first commit"
4) Add the remote repo
$ git remote add github https://github-url
5) Push the local repo to the remote repo
$ git push --set-upstream github master
After adding files for making changes
6) add newfile.txt to local git repo
$ git add newfile.txt
7) commit the changes (adding the new file / or if you’ve updated files)
$ git commit -m "added update script"
8) push the changes to github
$ git push --set-upstream github master
 
— How to undo chanages BEFORE A COMMIT —-
Use this command to see which files have changed
$ git diff
Then use the checkout command to replace the file with the changes you want to undo
$ git checkout <filename>
NOTE : this needs to happen BEFORE you do a commit.


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *