How to Git in Unity- part 3
Before we start to commit and push our update. We need to follow the steps to do it right in version control.
While a project is sharing between all the co-workers, some changes might lost if we didn’t follow the steps properly.
Always do the version control by:
PULL, COMMIT, PUSH
Make sure you pull the latest version of changes, then commit your part, then push it to repository.
Now we’re going to push our local files to repo.
As I mentioned in the previous article, we need to make the branch to main(which is default as master) first to prevent error.
1.We can create new branch by input:git branch -b main
2. With same namespace, it should be error free to pull from remote repo:git pull origin main
3. You can always check the status by the command:git status
The red parts show the local changes different from remote repo.
4. Add all the changes to be pushed by input:git add .
the period is the key which means “add all the files”.
5. Then we can push our changes to repo:git push origin main
6. After pushed, we can delete the empty branch “master”
Before we do it, we can make sure the current branches:git branch
It should reveal 2 branches, main(with star mark) and master.
7. Now you can delete branch master:git branch -D master
(upper letter D to force delete)
That’s it! Now you successfully push the branch “main” and without any error.