Shuvankar Paul Software Engineer, Strativ AB Magento eCommerce Website Development, Website Development Using Php and HTML and Cross-Platform application development using Appcelerator.

All common Git related problem & it’s the solution

1 min read

How do I configure git to ignore some files locally?

This is kind of common problem we face, like Can I ignore files locally not on git repository

First Method :

git update-index --assume-unchanged[<file>...]

For Example, if your file path is app/etc/env.php
So then the command will be

git update-index --assume-unchanged app/etc/env.php

Second Method :

git update-index --skip-worktree [<file>...]

For Example, if your file path is app/etc/env.php
So then the command will be

git update-index --skip-worktree app/etc/env.php

Note : If you need to know differenct between them you can view this article , https://stackoverflow.com/questions/13630849/git-difference-between-assume-unchanged-and-skip-worktree/13631525

Update git branches in Server as new branch is Created on Git

git fetch

Remove .git Folder Completely from Linux

Suppose you want to delete your project. So you delete all folder, but .git folder not get deleted by rm -r .git command, following error showing

rm: remove write-protected regular file .git/objects/58/8bed22a363934725fe07290591c0fbfcc21481

What you need to do run following command

rm -rf .git

Your branch is ahead of ‘origin/master’ or origin/any_brach by X commit

Reason : This is happen because your local repository is advance with some commit, this commit can happen by mistake or by unexpected reason. And if you have no clue which file got changes locally we can do, like reseting the last commit and git pull. That’s

For Example : My local repository is 2 commit ahead. so what will i do i run the reset of last commit and run git status

  1. First

    git status
    if this show, Your branch is ahead of ‘origin/master’ by 2 commit

  2. Secondly

    git reset –soft HEAD~
    it will reset last commit

  3. Thirdly

    git status
    then it should show, Your branch is ahead of ‘origin/master’ by 1 commit.
    Note : we will run the second and third step again until third step does’t show the ahead message

  4. Finally

    git pull origin branch_name
    Now you will sync with git repository

Shuvankar Paul Software Engineer, Strativ AB Magento eCommerce Website Development, Website Development Using Php and HTML and Cross-Platform application development using Appcelerator.

Leave a Reply

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