【Godot 教程】游戲開發(fā)的神器:掌握Godot和Git #3

Snopek Games: Godot and Git cheatsheet
?
Git for Windows:
?
https://gitforwindows.org/
?
Git BASH?= the Git command-line
Git GUI?= the Git graphical user interface
?
Commands to setup your Git identity:
?
●?git config --global user.name "John Doe"
●?git config --global user.email johndoe@example.com
?
Simple .gitignore for a Godot game project:
?
/.import/
/build/
# for C# projects:
/.mono/
# for Android projects:
/android/build/
?
Useful commands:
?
●?git init
○?Create a new repository in the current directory
●?git add FILE
○?“Stage” a file to be committed
●?git add .
○?“Stage” all files in this directory (and child directories) to be committed EXCEPT for the files that match .gitignore
●?git commit
○?Commit all staged
●?git commit -a
○?Commit all staged files AND any other files that are changed (which are already part of the the repository)
●?git status
○?Display information about the current state of the files in the working directory, for example, which files have changed since the last commit, have been staged, etc
●?git log
○?Show the revision history
●?git checkout COMMIT_OR_BRANCH
○?Checkout a specific commit or branch from the repository, so that the files you see are from that commit or branch
●?git checkout master
○?Return to latest commit on the ‘master’ branch
●?git checkout -- .
○?Undo any modi
○?fications to local files since the last commit
●?git diff
○?Show any modifications to local files since the last commit
●?git diff COMMIT..COMMIT
○?Show the differences between two commits
●?git revert COMMIT_ID
○?Reverts all changes made since the COMMIT_ID
○?
?
Command to generate your SSH key:
?
●?ssh-keygen -t rsa -b 4096
?
You only really need to do this once per machine that you want to access your Git repository.
?
Pushing and pulling your repository:
?
●?git remote add origin URL
○?Adds a remote called “origin” to your repository pointing at the given URL
●?git push -u origin BRANCH
○?Pushes the branch to the remote “origin” and sets it as its upstream (so future “git push” and “git push” commands will know to always push/pull that branch to that remote)
●?git push
○?Pushes the current branch to the remote which is set as its upstream
●?git pull
○?Pull the current branch from the remote which is set as its upstream
?
Branching and merging
?
●?git branch
○?Lists branches and tells you (via the asterisk) which branch you have currently checked out.
●?git checkout -b BRANCH
○?Creates a new branch (named BRANCH) locally
●?git branch -d BRANCH
○?Deletes a branch (named BRANCH) locally
●?git merge BRANCH
○?Merges BRANCH into your currently checked out branch (be sure to first checkout the branch you want to merge into first).
●?git merge --squash BRANCH
○?Do a “squash” merge of BRANCH into your currently checked out branch, which “squashes” all the commits in BRANCH down to a single commit
?
Remote Commands
?
●?git remote -v
○?List all the remotes of the repository
●?git remote rename <old_branch_name> <new_branch_name>
○?Renaming an existing branch
●?Git remote set-url <remote_name> <new_remote_url-or-ssh>
○?Replacing the url or ssh of an existing remote
●?Git remote add <remote_name> <remote_url-or-ssh>
○?Add a new remote for the repository
?
Git LFS
?
Download Git LFS client from: https://git-lfs.github.com/
?
●?git lfs install
○?Only need to do once per user account after installing the client from the link above.
●?git lfs track “*.glb”
○?All *.glb files added after running this command will use Git LFS
●?git lfs track --lockable “*.glb”
○?Same as the last command, but these files will also be lockable too
●?git lfs track --filename “Model.glb”
○?Use this to mark just a single file for Git LFS (as opposed to all files with a particular extension)
●?git lfs lock FILE
○?Lock a particular file, which will prevent other users from merging changes to it, or locking it
●?git lfs locks
○?Show all files that are currently locked
●?git lfst?unlock FILE
○?Unlock a file, so that other users can merge changes to it or lock it