Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
589 views
in Technique[技术] by (71.8m points)

git bash : how to check if there's a new commit available

I use git with my friend to collaborate on a project. He created a repo in github consisting folders of each of our names, so everytime i update something, I upload it to this folder then push it to github, and so does he. So everytime there's a new commit, we have to pull from github and copy paste the edited files to our own localhost (wamp).

So what i want to ask :

  1. How do I check if there's a new commit from git bash without checking github? Git pull will pull the latest version i know, but what if i just want to check first?

  2. Say my git folder is located in D://git/project_name. Can I copy this folder to another location (for example USB Flash Disk) then do a git pull from this USB?

  3. If our method isn't effective, do you have any proposal on how we should use git? We're using CodeIgniter framework, so at first I proposed to just git push the whole CodeIgniter folders, but my friend said it's dangerous (cos the whole config and database is there) and unnecessary (since the main system folder will most likely be untouched). So we're using this current method (having two folders with our names and pushing and pulling everytime there's an update.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Answering your first two questions in turn:

  1. Assuming that origin refers to the GitHub repository in each case, you should just run git fetch origin. Then the "remote-tracking branch" origin/master will be at the version of master on GitHub and you can compare it with your master with git diff master origin/master to see the difference between those two versions, or git log master...origin/master to see the commits which are unique to either master or origin/master.
  2. Yes, you can copy the repository to a USB stick and pull from there. However, if you want to pull from the USB key onto another computer, you'll want to set up a remote that refers to the location of the repository on the USB key.

With regard to whether there is a better way to do what you're doing, I'm afraid I don't understand clearly enough what you're doing or trying to achieve to comment sensibly. However, having folders in the repository named after each developer with (presumably) very similar source code in them sounds a little suspect - you would typically use branches to deal with divergent versions of the same code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...