Git & GitHub Key Commands





Basic command before learning git command  


Commands 

1.
Enter the folder
Cd directoryName [ cd htdocs ]
Cd = changing directory
2.
back from folder
Cd .. [cd space dot dot]

 3.
Current directory.
pwd
PWD = Print Working Directory

Directory te ki ki file aqche file er list
ls
Ls = List of the content of current directory
4.
Clear the bash
Ctrl+l  / clear

5.
Make new directory/folder
Mkdir directoryname [mkdir newfolder]

6.
Author Username and email configure
Git config --global

7.
Username
 Git config –global  user.name “username”

8.
Email
Git config –global  user.email  “email”

9.



10.
Git initialization
Git init
[get the .git hidden file in project]

11.
Check the user name and email:
git config --global --list

12.
Make any file
touch index.html

13.

Git status

14.
All file added
git add .

15.
Only selected file added
git add filename.extention

16.



17.

Git commit –m “comments”






Add-> commit  for complete any commit


19.
Get previous detail
Git log

19.

Git log -2
Get last 2 history /commands/commits
20.



21.
Delete a commit
git reset --hard b232e443cd5d2cac0070dace4608a5fb085cfc9b
[commit id/key]










new brance create 
Git checkout –b branchName


Switching a branch
Git checkout branchName







Git merge childBranchName


Delete branch
Git branch –d branchName







git push -u origin master




Tab
For auto filling command line














Git clone git_repo_url
For cloning github project to our computer.










-a
All


-m
message


Git config –list
Show all the info about git config [oviously local information]


Git remote



Git remote –v
Show the github path/url


-v
-v = verbose


Git push origin master
Git [action] [remote] [branch]


Git pull origin master
Git [action] [remote] [branch]





If we make a repository in our pc and then want to push to github … then we need to add that remote 1st then push to the remote
Git remote add origin the_url_of_repository
Git remote add [remote name] [remote url]







How to upload Laravel project on git hub è
1.       First install Laravel :
a.       composer create-project --prefer-dist laravel/laravel project_name
2.       Create an repository on git hub without Readme.md
a.       Copy the http: URL of repository
3.       Open git bash on your pc into the project directory
a.       Git init
b.       Git add . []
c.       If you want to know ignored file and add ignore files:
                                                               i.      git status –ignored
                                                             ii.      git add –f .
d.       Git commit –m “upload”
e.       ============================
f.        Now connect the git directory with github repository è
                                                               i.      Git remote add origin repository_url
                                                             ii.      Git remote –v
                                                            iii.      Git push origin master
                                                            iv.      ====================
g.       If you need to pull from githubègit :
                                                               i.      Git pull origin master
h.       \
4.       \


How to make clone:-
1.       Open git bash è
a.       Git clone git_repo_url
b.       Check the above “How to upload Laravel project on git hub” ….

=============================

For Any Laravel project clone from git:

Setting up the environment

  1. clone the git

  2. composer update --no-scripts

  3. cp .env.example .env

  4. php artisan key:generate

  5. Create db and change the credential inside the env file[DB name, Username, password]

  6. Before doing the migrate check if the AppServiceProvider is config for the 191 string length add the following line in the top of the AppServiceProvider.php file

    use Illuminate\Support\Facades\Schema;

Then add the following schema inside the boot function

  schema::defaultStringLength(191);

This will prevent from database error when migrated as the length will be 1024 and the mysql db gives default length 1000
7. php artisan migrate 8. php artisan migrate:refresh --seed (It will create a new user dummy one in the system automatically, admin, admin@gmail.com, secret plus all the needed seed for the catagory)


Comments