*Git Imp Commands*| Git Pages | Git Sub Module Problem




# Three Stages of file 

Untracked, Stage(M), Commit

To clone the repo..

git clone https://github.com/username/repo.git

How to push your code on github?

git init 

git remote add origin https://github.com/username/repo.git

git remote -v   (Gives our alias and URL name)

*Make changes*

git add .     (To Stage All Files)

git commit -m "changes info"

git push origin master  or git push origin master --force

How to get the changes from github to your local PC?

First of all, commit all your chnages before pulling

git add .

git commit -m "My change"

git pull origin master

// Merge options will appear

More info : https://docs.github.com/en/get-started/using-git/getting-changes-from-a-remote-repository

Branch Navigation..

git branch (to view all the branches )

git checkout -b myfeature   (To create new branch)

git checkout master (to switch ) 

To delete a branch: git branch -d <branch>

 Common  commands

git status

git log

ls

ls −a                //to see the hidden .git file

cd..

rm -rf filename

git show (to show particular file commits)

More info: https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes


Command to remove existing repo...

git remote remove origin

https://www.cloudbees.com/blog/remote-origin-already-exists-error

Steps to host your react app using Github Pages!!

Strictly follow below steps !!

https://create-react-app.dev/docs/deployment/

firstly add, commit , push 

and then npm run deploy

Git automatically initializes a submodule in a folder inside your main folder

To remove that just open vscode settings and go to exclude settings and exclude /.git from that 

Now you will be able to see the .git file 

just remove the .git file from the folder where submodule is created.

done

To delete the .git folder 

To list and delete the `.git` folder using the command line (cmd), you can follow these steps:

**Warning: Deleting the `.git` folder will permanently remove all version control information from your repository. Make sure you have a backup or are absolutely certain before proceeding.**

1. Open the Command Prompt (cmd) on your computer.

2. Navigate to the root directory of your Git repository using the `cd` command. For example:

   ```

   cd path\to\your\repository

   ```

   Replace `path\to\your\repository` with the actual path to your Git repository.

3. To list the `.git` folder and its contents, you can use the `dir` command with the `/ah` option (to display hidden folders and files):

   ```

   dir /ah

   ```

   This will show you a list of hidden folders and files, including the `.git` folder.

4. To delete the `.git` folder and all its contents, you can use the `rmdir` command with the `/s /q` options (which will remove the folder and its subdirectories without prompting for confirmation):

   ```

   rmdir /s /q .git

   ```

   After running this command, the `.git` folder and all of its contents will be permanently deleted from your repository.

Again, please be very cautious when using the `rmdir` command with the `/s /q` options, as it will delete the entire Git repository's version control history, and this action cannot be undone.

How to remove the node modules pushed into the github by mistake

Method 1st

  • Create a .gitignore file 
  • and add just node_modules in it.

Method 2nd

1. Create a .gitignore file with this entry.

node_modules

2. Remove the node_modules folder from the Git index using the git rm cached command.

git rm -r --cached node_modules

3. Commit the changes.

git commit -am "removed node_modules folder"

4. Push the changes to the remote.

git push origin master


Comments