- [[git pull]], [[git push]] # Idea ```bash # check if git is already initialized git init # rename master branch to main branch (if I'm already in master) git branch -m main # check if the local connected to the remote git remote -v # if not, create a connection to a remote repository on github (e.g., https://github.com/hauselin/private_datasets) git remote add origin <URL> git remote add origin https://github.com/hauselin/private_datasets.git # check current branch git branch --show-current # IF LOCAL (MAIN) DOESN'T HAVE ANY FILES IN THE REMOTE # pull (data) from remote (origin) to local (main) # remote files will be copied/downloaded to local # if local has files that aren't on remote, they will remain, untracked, in the directory git pull origin main # make local (main) branch track remote origin/main branch so just `git pull` works from now on git branch --set-upstream-to=origin/main # IF LOCAL (MAIN) HAS FILES ALREADY IN THE REMOTE # fetch data and commits from remote without merging any of the updates into local branches # if local has files that aren't on remote, they will remain, untracked, in the directory # IF THERE ARE LOCAL MODIFICATIONS TO FILES IN THE REMOTE, these changes will be deleted! git fetch origin # synchronize local main with remote origin/main # discard all changes on local main branch since it diverged from remote origin/main git reset --hard origin/main # make local (main) branch track remote origin/main branch so just `git pull` works from now on git branch --set-upstream-to=origin/main # other git pull options # merge unrelated histories git pull origin main --allow-unrelated-histories ``` # References