您的位置:首页 > 其它

Git basic

2015-07-04 14:31 411 查看
1. solve conflict

senario:

  Adam checked out master branch,

  then Bob checked out master branch,

  then Adam modify a file, commit and push,

  then Bob modify the same file,

  then Bob need to commit, then pull, then manually resolve the conflit, then commit again, then push.

2. ignore a tracking file, remove from remote

http://stackoverflow.com/questions/9237345/how-do-i-ignore-pycharm-configuration-files-in-a-git-repository

for single file

git rm --cached [filename]


for folder

git rm --cached -r [folder]


3. save password and username

http://stackoverflow.com/questions/11403407/git-asks-for-username-everytime-i-push

git config credential.helper store
git push http://example.com/repo.git[/code] 
4. compare file with last commit

git diff HEAD [filename]


5. revert file to last commit

http://stackoverflow.com/questions/692246/undo-working-copy-modifications-of-one-file-in-git

git checkout -- [filename]


6. only add tracking file

git add -u


7. download project

git remote add origin https://github.com/xxx.git git pull origin master


8. change origin (in case like repo name changed)

check remote

git remote -v


change remote origin

git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git[/code] 
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: