Unable to work effectively with Git locally

前端 未结 2 1399
我在风中等你
我在风中等你 2021-01-25 02:32

Please, see Greg\'s answer.

I do not understand Daniel\'s statement at the thread completely:

Why are you manually copying files around

相关标签:
2条回答
  • 2021-01-25 03:04

    I believe what Daniel was referring to is using Git to manage the files in particular directories in place, without copying them around. For example, starting without any Git repository, you might:

    cd ~/bin
    git init
    git add .
    

    Now, your ~/bin directory contains a ~/bin/.git repository and you can git add and git diff right from the ~/bin directory.

    0 讨论(0)
  • 2021-01-25 03:08

    1) I back up my .dotfiles as follows:

    a) Create a directory ~/dotfiles

    b) link dotfile into ~/dotfiles/ e.g.

    ln ~/.bashrc ~/dotfiles/.bashrc  # NB Must be hard links
    

    c)

    cd ~/dotfiles
    git init
    git add .  
    git commit -m "Initial commit of dotfiles"
    

    2) You can also refer to a Git repo not in the current directory tree by exporting the environment string GIT_DIR .e.g (assuming at repo at ~/myrepos/repo1)

    a)

     export GIT_DIR=~/myrepos/repo1/.git
    

    b)

     git add .profile  
     git commit -m "added .profile"
    

    Does that help at all?

    0 讨论(0)
提交回复
热议问题