Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

So I have two laptops sharing a github repo (and the same branch). An automated program on one of the laptops is modifying robot.txt and I am manually modifying math.html on the other laptop.

The question is, assuming both laptops have the correct time, how do I achieve the effect of cp -u with git in an automated bash script? Note that git merge --allow-unrelated-histories is not ideal as I frequently run into the case of manually typing git commands to resolve (non-existent) conflicts.

See Question&Answers more detail:os

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

1 Answer

You could:

  • pull changes
  • add your changes
  • commit these changes
  • push changes

Like:

git pull --rebase --autostash &&
git add -A &&
git commit -m "autosync: $(date -R)" &&
git push

With How do I programmatically determine if there are uncommitted changes? you could add a check if there are any changes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...