2

Still new to Github and was wondering if its possible to synchronize a WWW specific folder to Github project folder.

Let's say, I am working on /www/my-project/ and I have github folder /github/my-project-repo/ The main question is, how can I easily move file from my-project to my-project-repo just similarly to committing. Copy-pasting seems like a dull method to do. Any tips helps!

Ian
  • 151
  • 12

2 Answers2

1

Use the --git-dir and --work-tree option of the git command:

If you are modifying files in my_project, but want them taken into account in my-project-repo git repo, you can do:

git --work-tree=/www/my-project/ --git-dir= /github/my-project-repo/.git status
git --work-tree=/www/my-project/ --git-dir= /github/my-project-repo/.git add -A .
git --work-tree=/www/my-project/ --git-dir= /github/my-project-repo/.git commit -m "add files from my-project"

You might want to refresh your working tree in /github/my-project-repo after modifying its index with your git add.

cd /github/my-project-repo
git checkout .

Beware though of concurrent modifications you could have on common files: that last checkout would erase and overwrite them by what you added from /www/my-project.

If you want to be sure to preserve any work in progress in /github/my-project-repo:

 git stash save --keep-index
 git stash drop

The OP found a simpler solution, and:

  • moved the storage directory to /www/.
  • cd /my-project/,
  • git config, git init, etc.

I stop tracking the repo that was save on Docs/Github/ — my first storage directory.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • how do I pass correct directory path? My current wamp directory is c:\wamp\www\my-project\ and my github directory c:\users\xxx\Documents\GitHub – Ian Jan 14 '13 at 18:21
  • @edden put your wamp directory as working tree in the `--work-tree` parameter, and `c:\users\xxx\Documents\GitHub\.git` in the `--git-dir` parameter. Those two parameters allow you to pass the correct directory paths. – VonC Jan 14 '13 at 19:51
0

Finally figure it out... Here are some video tutorial that helped me along the way:

http://www.youtube.com/watch?feature=player_embedded&v=mYjZtU1-u9Y

  • Basic fundamentals of Git
  • The difference between Git and GitHub
  • Installation and setup tutorial for Git
  • Basic (but core) command lines of Git

http://www.youtube.com/watch?feature=player_embedded&v=8r_IErxmoUc

  • Account signup tutorial for GitHub and general tips
  • Using GitHub with Git (configuration and demo)
  • Installation tutorial of GitHub Windows Client (GUI)
  • Introduction to Branching, Merging, Cloning, and Forking

http://www.youtube.com/watch?feature=player_embedded&v=STJBFXskfCc

  • Example of development cycle using Git and GitHub
  • More details on Branching, Merging, Cloning, and Forking
  • Introduction to Merging Conflicts

http://www.youtube.com/watch?v=LCv2BIQpPgI&feature=player_detailpage

  • In-depth look in Merging Conflicts
  • Tagging
  • Reverting Commits
Ian
  • 151
  • 12
  • So what was your sequence of (git) commands that allowed you to solve your issue? – VonC Jan 21 '13 at 08:49
  • the basic to say the least. All I did was the move storage directory to /www/. did a git cd /my-project/, git config, git init, etc. I stop tracking the repo that was save on Docs/Github/— my first storage directory. To say the least, I was really new to git and github so I have no idea what I am doing even at the start at the beginning of installation. – Ian Jan 21 '13 at 17:32
  • Sounds good enough. I have including your comment in my answer for more visibility. – VonC Jan 21 '13 at 19:35