git bash for windows

git for woindows

install git bash

Reference link

Main tasks to be done

Test if connected to ssh

ssh -T [email protected]

After entering the password, if the prompt is successful, it is connected correctly

Copy files from github to local

cd e:/git  # 切换本地文件夹
mkdir repo # 新建文件夹,之后clone的文件都存放在这里
cd repo/   # 切换到repo文件夹中(所在文件夹尽量是空文件夹,否则容易产生错误)
git init   # 初始化
git clone https://github.com/yourusername/yourepositoryname  # 将网址所在的仓库复制到当前文件夹    

For some folders that have been initialized due to misoperation, git will be generated in the folder, ./gitand reinit will be displayed after init. At this time, you can rm -rf ./gitdelete the folder and thengit init

If prompted remote origin already exists., just run it git remote rm origin. Reference link

Upload the local project folder to the established empty repository on github

cd f:/prj  # 切换文件夹
git status # 查看git状态
git init   # git初始化
git add .  # 添加当前文件夹中所有文件到本地仓库
git commit -m "first commit" # 添加commit
git remote add origin https://github.com/yourusername/yourepositoryname.git
git push -u origin master

Reference link

Modify the project locally, submit it to git, and merge it with the remote file

git init #初始化,如果已经初始化之后则不需要
git remote add origin [email protected]:yourusername/yourrepositoryname.git # 如果提示已经存在则无需添加
git status #查看是否有需要增加的内容,根据提示增加即可
git add .  #增加需要上传的内容,在此添加了所有文件
git status #查看修改后的状态
git commit -m "upload after modification on PC" #修改细节,这一句必须加,否则上传不成功
git remote add origin # 添加到远程仓库中
git push -u origin master

Some tutorials say that you may encounter errors. I did not encounter errors here. I posted some reference links: http://www.cnblogs.com/fnng/archive/2012/01/07/2315685.html

Modify the project remotely and synchronize it to the local

# git init
# git remote add origin [email protected]:yourusername/yourrepositoryname.git # 如果提示已经存在则无需添加
# git pull origin master # 将

Notice

  • For the above methods, if different files in a project have been modified, such as modifying file A locally and modifying file B remotely, the old remote file A will not overwrite the locally modified file during pull. file A, but the local old file B will be overwritten.
  • Other cases not yet tested
  • When creating githuba new one repositoryon the website, if you choose to add a readme or license , there will be problems when you submit the local project to the website for the first time . At this time, you need to follow the steps below.Updates were rejected because the remote contains work that you do not havegit refusing to merge unrelated histories

    git merge origin/master --allow-unrelated-histories
    git push -u origin master
    

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325485961&siteId=291194637