简体   繁体   中英

How to commit a Git file locally?

I want to commit a file to a Git repository locally for my sample projects

Failed Attempts to Commit File Locally

Divyanshu (master +) asteroids $ git commit -m "Fire one bullet at a time"

fatal: cannot lock ref 'HEAD': Unable to create 'C:/Users/Divyanshu/Desktop/dktop/focus/
Udacity/Git-hub/version-control/repositories/asteroids/.git/refs/heads/master.lock': 
File exists.

Another git process seems to be running in this repository, e.g. an editor opened by 'git 
commit'. Please make sure all processes are terminated then try again. If it still fails,
a git process may have crashed in this repository earlier: remove the file manually to 
continue.

Follow these steps:

  • Close all the Git terminal or any other editors that are accessing files of that repository

  • Go to this path: C:/Users/Divyanshu/Desktop/dktop/focus/Udacity/Git-hub/version-control/repositories/asteroids/.git/refs/heads/master.lock

  • Delete the file named master.lock

  • Run your Git terminal again in administrator mode

Then you should try commiting again!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM