1

I have a github account and have been pushing stuff there for months. I don't really know how to use git, but that hasn't really been a problem since I am the only one working on the project. (I thought that by getting an account I would start to get some experience with version control...)

Anyhow, I normally work from my desktop but I am about to go travelling so need to get my laptop working.

A few months ago I was about to do the same thing so I went to my laptop, got it connected to github, and cloned the repository. That's all I did though, since the trip got cancelled.

After reading around the web today I went to the laptop and did a git pull origin master. This seemed to be going OK, but it suddenly halted saying that local changes would be overwritten by the merge, then listing the files. I am happy to overwrite these changes, but I'm not sure how to do it.

Basically, to date I have just been issuing the following commands from my desktop:

git add .
git commit - m 'my message here'
git push origin master

I would now like to be able to:

  • Pull code down to my laptop and modify it
  • Push the changes back to github
  • Pull the changes down to my desktop (where I return from my travels!)
  • (Repeat the above whenever I travel again...)

Ideally I'd like to be able to exclude some files from being tracked (e.g. htaccess) since they depend on which machine I am using. (This is not imperative though, since I can manually back them up and restore them...)

Can you make this easy for me? I have read several tutorials online but none dealing with this exact scenario, and all slightly different...

DatsunBing
  • 7,624
  • 11
  • 71
  • 141

1 Answers1

3
  • "I am happy to overwrite these changes, but I'm not sure how to do it."

    git reset --hard
    git pull origin master
    
  • You can use git in your new computer exactly the same way as you do in your old computer.

  • "Ideally I'd like to be able to exclude some files from being tracked..."

Create .gitignore in the same directory and put the names of the files to exclude in it.

If you're using windows, How to create .gitignore file

Community
  • 1
  • 1
jaeheung
  • 1,188
  • 5
  • 7