You can also go back to the previous commit ( git reset -hard) and you LOSE all uncommit files. # use sudo if needed # error: invalid object Error building trees Problem with pre-commit? (Cannot removing it?) rm. Clone again the repo and it shoule be working!.Go to Gitlab > Settings > SSH Keys > paste a copied key and name it.Open and copy key in C:\Users\dinha\.ssh\id_rsa.pub.(Windows) Generate a ssh key ssh-keygen -t rsa -b 4096 -C " " in C:\Users\dinha\.ssh under the name id_rsa (for private) and id_rsa.pub for public.Git config alias.br branch Gitlab: Clone a private repo to local Git remote set-url origin /here Alias # use `git br` instead of `git branch` Git push -f origin master Change remote url # check the current remote url Git reset -hard # EREASE ALL COMMITS + BACK TO Git reset -hard origin/master # DISCARD ALL CHANGES + get the last update from remote Git checkout - # DISCARD ALL CHANGES ON LOCAL + GET FROM REMOTE Git checkout - # Revert single file to a commit Git push -f origin # Force push branch to github Remove from git Git branch -m # Rename the current branch to Git branch -D # Deletes the branch on remote Git add -A # Add all files and commit them Tags # Listing tagsĬlean all history of a repo, git checkout -orphan tmp_repo In the case you wanna exit Vim, press ESC then type :q to quit or :wq to write and quit. Git push origin -u Squash # Squash newest 5 commitsĪdd a description (using Vim editor): git branch -edit-description # reset the upstream branch for the new-name local branch Git branch -m # RENAME REMOTE BRANCH (delete old + push new) Git branch -M # if there are only capitalization changes # CURRENT IS ANOTHER BRANCH Git commit -m "update from merge (keep local in some folders)"Įach time, git merge & sh reset_folders.sh If you meet a conflict, add the folder's name in a file called reset_folders.sh, #!/bin/shĮcho 'Reset some only-this-branch folders after merging.' If you delete these folders after merging, just commit and later merges will ignore them. gitattributesĮxclude some folders (we cannot use git in this case): gitattributes (on branch being merged)Įcho "file.ext merge=ours". Git checkout -ours path/to/file # local # Abort the conflictsĮxclude some files from merge (keep ours), # ONLY FOR FILES Git checkout -theirs path/to/file # remote If you use Visual Studio Code, there is a small toolbar above each conflict and you can choose which one you prefer to keep! If there are changes from both local and remote, there will be conflicts! Something likes that, > template/notetheme2 Git cherry-pick # KEEP FILES/FOLDERS FROM MERGEĮcho 'file_name.txt merge=ours' >. Git checkout folder1 \ folder2 \ # MERGE commit from ONE BRANCH to CURRENT Git checkout branch-1 /link/to/abc.xyz # MERGE ONLY SOME FOLDER Git checkout folder/* # MERGE `/link/to/abc.xyz` FROM `` TO `` (can be `master`) # master can be other # Merge all files in a folder frm another commit Git merge -strategy-option theirs # MERGE TO master + REPLACE master Git_pass 4 "commit message" # "4" means 4 hours ago! Pull & Fetch GIT_AUTHOR_DATE = " $( date -v -$1H )" GIT_COMMITTER_DATE = " $( date -v -$1H )" git commit -m " $2" # In case you wanna use an alias, put below in. GIT_AUTHOR_DATE = 'Mon Feb 20 11:12:' GIT_COMMITTER_DATE = 'Mon Feb 20 11:12:' git commit -m "Commit message" Git commit -m "Updated: ` date + '%Y-%m-%d %H:%M:%S' `" # Updated: 10:22:06 # Commit with a custom date (in the pass)ĭate -v -6H # 6 hours ago -> Mon Feb 20 11:12: Git commit -m " ` date `" # Wed Aug 28 10:22: Git checkout # back to previous # Commit current date Git push -all origin # push all branches # CHECK & TEST A COMMIT Git commit -a # commit any files # UNCOMMIT (back to before commit)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |