Skip to content

Latest commit

 

History

History
218 lines (185 loc) · 3.59 KB

File metadata and controls

218 lines (185 loc) · 3.59 KB

Allow unrelated histories

git pull origin master --allow-unrelated-histories

Initialize Git and GitHub Project:

  1. In the folder, write in the terminal:
git init
  1. Untracked files are shown
git status
  1. Stage files to add
git add test.py
git add .
  1. Show status again
git status
  1. Create a new version. Each version has its own title.
m - message
git commit -m 'First version of the project!'
git commit -am "When something should be deleted use this!"
  1. Shows the latest commit
git log

to exit log: - q

  1. Not needed, a way to register:
git config --global user.name "Vitosh"
git config --global user.email "mail@mail.mail"
  1. Shows the different versions
git diff
  1. Create new repository at github:
https://github.com/new
  1. Remotes per repository
git remote -v
vman@vman-Studio-1555:~/Desktop/TestRepo$ git remote -v
origin	https://github.com/Vitosh/TestRepo.git (fetch)
origin	https://github.com/Vitosh/TestRepo.git (push)
  1. Add a remote repository
git remote add {Name} {Address}
git remote add origin https://github.com/Vitosh/TestRepo.git
  1. Push
git push -u origin master
  1. Delete remote directory:
git remote rm origin
  1. Adding the repo:
git remote add origin git@github.com:Vitosh/TestRepo.git
  1. Make SSH - Secure Shell
  1. Pulling
git pull origin master
  1. History Commits
  1. Cloning the repo
git clone git@github~
  1. Remove directory from git and local
git rm -r one-of-the-directories
git commit -m "Remove duplicated directory"
git push origin master
  1. Using branches
git branch rado
git checkout rado
  • switched to branch rado
git checkout master
git push origin rado
git branch
  • => returns a list of all branches
git merge rado
  • history from rado goes to the master
git branch --delete rado
  • (deletes) local master on the HD
git push origin --delete rado
  • (deletes) master on the cloud
  • generate collaborator:
touch B
echo "AA" >> B
cat B
AA
  1. Fetch git pull = git fetch + git merge

  2. Adding upstream

git remote add upstream https://~
  1. git pull --rebase upstream master

  2. if you **** ** and you need to reset git:

git reset --hard a0d3fe6
where a0d3fe6 is found by doing
git reflog
  1. Git overwrite local files with pull request
git fetch --all
git reset --hard origin/master
git pull origin master

TLDR:

git add .
git commit -m "some message here"
git status
git push origin master

Rename repository:

  • Rename the repository manually. Then run the command to see the new name.
git config --list
remote.origin.url=ssh://git@git.example.com/newNameHere.git
  • Run Git to change the name
git remote set-url origin https://git.example.com/newNameHere.git

Remove Git from local folder

Navigate to the folder

  • Windows:
del /F /S /Q /A .git
rmdir .git
  • Linux: rm -rf .git*

Overwrite the current changes

Get exact Git from the origin to overwrite the current changes:

git fetch --all
git reset --hard origin/master

https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files

Remove local untracked files:

git clean -n
git clean -f

Get specific branch:

git init
git remote add origin https://github.com/Vitosh/VBA_personal.git
git fetch --all
git checkout develop

pic