Generic Git Commands List
Wed Feb 02 2022 21:56:04 GMT+0000 (Coordinated Universal Time)
# Initialise local repo git init # Stage files to index git add <file> # Check status of working tree git status # Commit changes in index git commit # Push to remote repository git push # Pull latest from remote repository git pull # Clone repository into a new directory git clone ########### # Configure ########### # Setup git config --global user.name '<name>' git config --global user.email '<email>' git config --global init.defaultBranch main # Protocol git config --global default.protocol ssh # Long path support git config --global core.longpaths true # GPG signatures git config --global gpg.program '<path to gpg>' git config --global user.signingKey '<GPG signature>' git config --global commit.gpgSign true git config --global tab.forceSignAnnotated true # Globals git config --global core.excludesFile = '<path to global .gitignore>' git config --global core.attributesFile = '<path to global .gitattributes' # Color git config --global color.ui true ################# # Staging Process ################# # Stage file git add <file name> # Un-Stage File git rm <file name> # Add all *.py files git add *.py # Add Everything that has changed git add . # or git add * ################# # Commit Process ################# # Commit staging area to your local repository git commit -m "<commit message>" ############# # Branching ############# git branch <branch_name> # Create branch git checkout <branch_name> # move to branch git add <filename> # add file change to branches git commit -m "comments" # commit file and add comments git checkout <master> # move to main branch git merge <branch name> # merge branch into current branch location git push # push branch to hub git branch -d <branch> # delete branch #################### # Remote Repository #################### # list all remote repositories git remote # add origin (HTTPS) git remote add origin 'https://github.com/<user>/<repo>.git # add origin (SSH) git remote add origin 'git@github.com:<user>/<repo>.git' # initialize origin in first push git push -u origin main # or master
Comments