Practical git commands at work (used to record at hand)

git rm -r --cached ./springModules deletes remote warehouse files directly after deleting cache commit and push, local files will not be deleted

Cancel a submitted version

1、git log 

     Find the version id1 to be revoked

      Version id2 before commit

2、git reset –hard id1
3、git reset id2

Update the git branch list

git remote update origin --prune

Check which branch the branch was created from
git reflog show space/json

Pull a new branch from an existing branch
git checkout -b space/xxx-test origin/space/xxx
Push the new branch to the remote
git push origin space/xxx-test

 

 

Upload the local project to the remote warehouse using the git command line

1. Create a new repository remotely;

2. Open the command line and enter the project directory to initialize the local warehouse

git init

3. Associate remote warehouses and local warehouses

git remote add origin http://gogs.xxx.com.cn/xxx/enterprise.git
Fourth, add the project to the staging area

git add .

Five, submit the project

 git commit -m "xxx rewrite project first commit"

Six, push to the remote

git push origin master

An error is reported at this time:

To http://gogs.xxx.com.cn/xxx/enterprise.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'http://gogs.xxx.com.cn/xxx/enterprise.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

There is a difference between the local version and the trunk. In this case, the conflict must be resolved first:

git pull --rebase origin master

Perform the sixth step again successfully.

Guess you like

Origin blog.csdn.net/noob9527/article/details/89310371