Last active
February 12, 2024 05:52
-
-
Save jack2jm/12ada53a6d07f05ed033d35e89e5f755 to your computer and use it in GitHub Desktop.
Learn how to create a Git repository, clone it, make changes, and submit changes to GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. install git. | |
| 2. Create repository | |
| 3. Copy Clone Url | |
| *********** Clone Project ************** | |
| Commadn: git clone clone_url here_folder_name_ifspecify | |
| e.g git clone https://github.com/...../test.git example_repo | |
| ********** ******* Git Status ********* ************ | |
| Command: git status | |
| It showing untracked files. Commits etc. | |
| ********** ******* Git Add Files ********* ************ | |
| Command: git add filepath/filename | |
| It adding file to git repo. but not stored to repo. | |
| ********** ******* Git Add Files ********* ************ | |
| Command: git add filepath/filename | |
| It adding file to git repo. but not stored to repo. | |
| ***************** Git Commit *************************** | |
| Command: git commit -m "intial commit" filename_with_path | |
| -m : message - string | |
| not sent to repo. its committed only. | |
| ***************** Git Push *************************** | |
| Command: git push origin master | |
| master - like index.html of main folder | |
| origin - where to come. | |
| //it will be asked for password and username. login with your credential | |
| // if error occure 403 - open ./git/config file - change | |
| git remote set-url origin ssh://[email protected]/derekerdmann/lunch_call.git | |
| ***or this can work*** | |
| 1. edit .git/config file under your repo directory | |
| 2. find url=entry under section [remote "origin"] | |
| 3. change it from url=https://[email protected]/derekerdmann/lunch_call.git to [email protected]/derekerdmann/lunch_call.git. that is, change all the texts before @ symbol to ssh://git | |
| 4. Save config file and quit. now you could use git push origin master to sync your repo on GitHub | |
| **** git status | |
| It will shows - On branch master - Your branch is up to date with 'origin/master'. | |
| ************** Create new file and change int README.md file **************** | |
| Command: git status | |
| //this will shows 1 README.md file has modified | |
| // also shows 1 brand new file is there which not added to REPO. | |
| ************* Check Diff ********************** | |
| Command: git diff filename | |
| //it will shows current file changes with commited file from repo. | |
| //it will show up +/- with green red color changes | |
| // red - removed line | |
| // green - changes mad in this line or added | |
| ************ Check commited git Log **************** | |
| Command: git log | |
| //it showing last logs from git. like first commit with time, second commit. | |
| ********* Never store API/Credircard/Passwords to this - its public ************ | |
| ************************ Show Commit changes by Commit ID *********************** | |
| Command: | |
| git show cbe1249b140dad24b2c35b15cc7e26a6f02d2277 | |
| ********* Reverse File Changes ************ | |
| Command: git checkout filename | |
| // this will erase your existing code from file. and file was same it is in REPO. | |
| ********* Reverse File Changes ************ | |
| Command: git checkout filename | |
| // this will erase your existing | |
| ********* checkout commit if not working | |
| Command: git log | |
| //copy git commit id where you want to go back to code | |
| git checkout git_commit_id | |
| // this will undo your all changes to copiesd git commit version | |
| git checkout master | |
| //this will back to your last commit | |
| ********** RUn this command to show log very pretyy | |
| Command: git log --topo-order --all --graph --date=local --pretty=format:'%C(green)%h%C(reset) %><(55,trunc)%s%C(red)%d%C(reset) %C(blue)[%an]%C(reset) %C(yellow)%ad%C(reset)%n' | |
| ********** Use Gitlab.com for private repository - 0$ charge, github 7$ taking per repo.****** | |
| Setting username | |
| git config --global user.name "Jerry Mouse" | |
| Setting user email | |
| git config --global user.email "[email protected]" | |
| Color highlighting | |
| git config --global color.ui true | |
| git config --global color.status auto | |
| git config --global color.branch auto | |
| Set Default Editor | |
| git config --global core.editor vim | |
| List Git Setting | |
| git config --list | |
| ******************************************************************** | |
| Life Cycle - https://www.tutorialspoint.com/git/images/life_cycle.png | |
| ******************************************************************* | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment